本文整理汇总了Java中org.apache.solr.response.ResultContext类的典型用法代码示例。如果您正苦于以下问题:Java ResultContext类的具体用法?Java ResultContext怎么用?Java ResultContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ResultContext类属于org.apache.solr.response包,在下文中一共展示了ResultContext类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: process
import org.apache.solr.response.ResultContext; //导入依赖的package包/类
@Override
public void process(ResponseBuilder rb) throws IOException {
SolrParams params = rb.req.getParams();
if (!params.getBool(COMPONENT_NAME, false)) return;
SolrIndexSearcher searcher = rb.req.getSearcher();
IndexSchema schema = searcher.getSchema();
if (schema.getUniqueKeyField() == null) return;
ResultContext rc = (ResultContext) rb.rsp.getValues().get("response");
if (rc.docs.hasScores()) {
processScores(rb, rc.docs, schema, searcher);
} else {
processIds(rb, rc.docs, schema, searcher);
}
}
开发者ID:europeana,项目名称:search,代码行数:18,代码来源:ResponseLogComponent.java
示例2: testNotLazyField
import org.apache.solr.response.ResultContext; //导入依赖的package包/类
@Test
public void testNotLazyField() throws IOException {
assertU(adoc("id", "7777",
"title", "keyword",
"test_hlt", mkstr(20000)));
assertU(commit());
SolrCore core = h.getCore();
SolrQueryRequest req = req("q", "id:7777", "fl", "id,title,test_hlt");
SolrQueryResponse rsp = new SolrQueryResponse();
core.execute(core.getRequestHandler(req.getParams().get(CommonParams.QT)), req, rsp);
DocList dl = ((ResultContext) rsp.getValues().get("response")).docs;
Document d = req.getSearcher().doc(dl.iterator().nextDoc());
// ensure field in fl is not lazy
assertFalse( ((Field) d.getField("test_hlt")).getClass().getSimpleName().equals("LazyField"));
assertFalse( ((Field) d.getField("title")).getClass().getSimpleName().equals("LazyField"));
req.close();
}
开发者ID:europeana,项目名称:search,代码行数:22,代码来源:BasicFunctionalityTest.java
示例3: getDocListSize
import org.apache.solr.response.ResultContext; //导入依赖的package包/类
private int getDocListSize(String query)
{
SolrQueryRequest request = null;
try
{
request = this.getLocalSolrQueryRequest();
ModifiableSolrParams params = new ModifiableSolrParams(request.getParams());
params.set("q", query);
// Sets the rows to zero, because we actually just want the count
params.set("rows", 0);
ResultContext resultContext = cloud.getResultContext(nativeRequestHandler, request, params);
int matches = resultContext.docs.matches();
return matches;
}
finally
{
if (request != null) { request.close(); }
}
}
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:20,代码来源:SolrInformationServer.java
示例4: exists
import org.apache.solr.response.ResultContext; //导入依赖的package包/类
/**
* Returns whether or not a doc exists that satisfies the specified query
* @param requestHandler the handler that handles the request
* @param request the request object to put the query on
* @param query the string that specifies the doc
* @return <code>true</code> if the specified query returns a doc
*/
boolean exists(SolrRequestHandler requestHandler, SolrQueryRequest request, String query)
{
ModifiableSolrParams params = new ModifiableSolrParams(request.getParams());
// Sets 1 because this is effectively a boolean query to see if there exists a single match
params.set("q", query).set("fl", "id").set("rows", "1");
ResultContext rc = this.getResultContext(requestHandler, request, params);
if (rc != null)
{
// TODO Should we use rc.docs.matches() instead?
if (rc.docs != null) { return rc.docs.iterator().hasNext(); }
}
return false;
}
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:23,代码来源:Cloud.java
示例5: process
import org.apache.solr.response.ResultContext; //导入依赖的package包/类
@Override
public void process(ResponseBuilder rb) throws IOException {
SolrParams params = rb.req.getParams();
if (!params.getBool(COMPONENT_NAME, false)) return;
IndexSchema schema = rb.req.getSchema();
if (schema.getUniqueKeyField() == null) return;
ResultContext rc = (ResultContext) rb.rsp.getValues().get("response");
SolrIndexSearcher searcher = rb.req.getSearcher();
if (rc.docs.hasScores()) {
processScores(rb, rc.docs, schema, searcher);
} else {
processIds(rb, rc.docs, schema, searcher);
}
}
开发者ID:pkarmstr,项目名称:NYBC,代码行数:18,代码来源:ResponseLogComponent.java
示例6: testUngrouped
import org.apache.solr.response.ResultContext; //导入依赖的package包/类
@Test
@SuppressWarnings("rawtypes")
public void testUngrouped() {
ModifiableSolrParams params = new ModifiableSolrParams();
NamedList results = test(params, "xjoin");
testXJoinResults(results, "xjoin");
ResultContext response = (ResultContext)results.get("response");
DocList docs = response.getDocList();
assertEquals(2, docs.size());
DocIterator it = docs.iterator();
assertTrue(it.hasNext());
assertEquals(1, it.nextDoc());
assertTrue(it.hasNext());
assertEquals(3, it.nextDoc());
assertFalse(it.hasNext());
}
开发者ID:flaxsearch,项目名称:BioSolr,代码行数:17,代码来源:TestXJoinSearchComponent.java
示例7: testUngrouped
import org.apache.solr.response.ResultContext; //导入依赖的package包/类
@Test
@SuppressWarnings("rawtypes")
public void testUngrouped() {
ModifiableSolrParams params = new ModifiableSolrParams();
NamedList results = test(params, "xjoin");
testXJoinResults(results, "xjoin");
ResultContext response = (ResultContext)results.get("response");
DocList docs = response.docs;
assertEquals(2, docs.size());
DocIterator it = docs.iterator();
assertTrue(it.hasNext());
assertEquals(1, it.nextDoc());
assertTrue(it.hasNext());
assertEquals(3, it.nextDoc());
assertFalse(it.hasNext());
}
开发者ID:flaxsearch,项目名称:BioSolr,代码行数:17,代码来源:TestXJoinSearchComponent.java
示例8: setUp
import org.apache.solr.response.ResultContext; //导入依赖的package包/类
@Before
public void setUp() {
rh1 = mock(SearchHandler.class);
rh2 = mock(SearchHandler.class);
rh3 = mock(SearchHandler.class);
qrequest = mock(SolrQueryRequest.class);
qresponse = mock(SolrQueryResponse.class);
args = new SimpleOrderedMap<>();
args.add(
InvisibleQueriesRequestHandler.CHAIN_KEY,
SAMPLE_VALID_CHAIN.stream().collect(joining(",")));
params = new ModifiableSolrParams().add(SAMPLE_KEY, SAMPLE_VALUE);
core = mock(SolrCore.class);
when(qrequest.getCore()).thenReturn(core);
when(core.getRequestHandler(REQUEST_HANDLER_1_NAME)).thenReturn(rh1);
when(core.getRequestHandler(REQUEST_HANDLER_2_NAME)).thenReturn(rh2);
when(core.getRequestHandler(REQUEST_HANDLER_3_NAME)).thenReturn(rh3);
cut = new InvisibleQueriesRequestHandler();
positiveResult = mock(ResultContext.class);
docList = mock(DocList.class);
when(docList.size()).thenReturn(1);
when(positiveResult.getDocList()).thenReturn(docList);
}
开发者ID:spaziocodice,项目名称:invisible-queries-request-handler,代码行数:31,代码来源:InvocationChainTestCase.java
示例9: testGroupingSimpleFormatArrayIndexOutOfBoundsExceptionWithJavaBin
import org.apache.solr.response.ResultContext; //导入依赖的package包/类
@Test
public void testGroupingSimpleFormatArrayIndexOutOfBoundsExceptionWithJavaBin() throws Exception {
assertU(add(doc("id", "1", "nullfirst", "1")));
assertU(add(doc("id", "2", "nullfirst", "1")));
assertU(add(doc("id", "3", "nullfirst", "2")));
assertU(add(doc("id", "4", "nullfirst", "2")));
assertU(add(doc("id", "5", "nullfirst", "2")));
assertU(add(doc("id", "6", "nullfirst", "3")));
assertU(commit());
SolrQueryRequest request =
req("q", "*:*","group", "true", "group.field", "nullfirst", "group.main", "true", "wt", "javabin", "start", "4", "rows", "10");
SolrQueryResponse response = new SolrQueryResponse();
ByteArrayOutputStream out = new ByteArrayOutputStream();
try {
SolrRequestInfo.setRequestInfo(new SolrRequestInfo(request, response));
String handlerName = request.getParams().get(CommonParams.QT);
h.getCore().execute(h.getCore().getRequestHandler(handlerName), request, response);
BinaryResponseWriter responseWriter = new BinaryResponseWriter();
responseWriter.write(out, request, response);
} finally {
request.close();
SolrRequestInfo.clearRequestInfo();
}
assertEquals(6, ((ResultContext) response.getValues().get("response")).docs.matches());
new BinaryResponseParser().processResponse(new ByteArrayInputStream(out.toByteArray()), "");
out.close();
}
开发者ID:europeana,项目名称:search,代码行数:31,代码来源:TestGroupingSearch.java
示例10: getDocList
import org.apache.solr.response.ResultContext; //导入依赖的package包/类
/**
* Returns the doc list resulting from running the query
* @param requestHandler the handler that handles the request
* @param request the request object to put the query on
* @param query the string that specifies the docs
* @return the docs that come back from the query
*/
DocList getDocList(SolrRequestHandler requestHandler, SolrQueryRequest request, String query)
{
// Getting the doc list is shard-specific, and not really cloud-friendly
ModifiableSolrParams params = new ModifiableSolrParams(request.getParams());
// Sets MAX_VALUE to get all the rows
params.set("q", query).set("fl", QueryConstants.FIELD_SOLR4_ID).set("rows", Integer.MAX_VALUE);
ResultContext rc = this.getResultContext(requestHandler, request, params);
return rc != null ? rc.docs : null;
}
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:18,代码来源:Cloud.java
示例11: getResultContext
import org.apache.solr.response.ResultContext; //导入依赖的package包/类
/**
* @param requestHandler the handler that handles the request
* @param request the request object to put the params on
* @param params Solr parameters
* @return the result context from the handled request
*/
ResultContext getResultContext(SolrRequestHandler requestHandler, SolrQueryRequest request, SolrParams params)
{
SolrQueryResponse solrRsp = getResponse(requestHandler, request, params);
ResultContext rc = (ResultContext) solrRsp.getValues().get("response");
return rc;
}
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:13,代码来源:Cloud.java
示例12: testSelect
import org.apache.solr.response.ResultContext; //导入依赖的package包/类
@Test
public void testSelect()
{
SolrParams params = new ModifiableSolrParams(request.getParams());
ResultContext rc = cloud.getResultContext(super.aftsRequestHandler, request, params);
assertNull(rc);
}
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:8,代码来源:CloudTest.java
示例13: testSimpleXJoinResultsFactory
import org.apache.solr.response.ResultContext; //导入依赖的package包/类
@Test
@SuppressWarnings("rawtypes")
public void testSimpleXJoinResultsFactory() {
ModifiableSolrParams params = new ModifiableSolrParams();
params.add("fl", "*, score");
params.add("xjoin", "false");
params.add("xjoin5", "true");
params.add("xjoin5.fl", "*");
// score boosts using value source parser
params.add("defType", "edismax");
params.add("bf", "xjoin5(value)");
NamedList results = test(params, "xjoin5");
ResultContext response = (ResultContext)results.get("response");
DocList docs = response.getDocList();
assertEquals(2, docs.size());
DocIterator it = docs.iterator();
assertTrue(it.hasNext());
assertEquals(0, it.nextDoc());
double score0 = it.score();
assertTrue(it.hasNext());
assertEquals(2, it.nextDoc());
double score2 = it.score();
assertFalse(it.hasNext());
// bf score boost for testid=0 only
assertTrue(score0 > score2);
List externalList = (List)((NamedList)results.get("xjoin5")).get("external");
NamedList hit0 = (NamedList)externalList.get(0);
assertEquals("0", hit0.get("joinId"));
NamedList doc0 = (NamedList)hit0.get("doc");
assertEquals("red", doc0.get("colour"));
assertEquals(10.5, doc0.get("value"));
}
开发者ID:flaxsearch,项目名称:BioSolr,代码行数:37,代码来源:TestSimple.java
示例14: testSimpleXJoinResultsFactory
import org.apache.solr.response.ResultContext; //导入依赖的package包/类
@Test
@SuppressWarnings("rawtypes")
public void testSimpleXJoinResultsFactory() {
ModifiableSolrParams params = new ModifiableSolrParams();
params.add("fl", "*, score");
params.add("xjoin", "false");
params.add("xjoin5", "true");
params.add("xjoin5.fl", "*");
// score boosts using value source parser
params.add("defType", "edismax");
params.add("bf", "xjoin5(value)");
NamedList results = test(params, "xjoin5");
ResultContext response = (ResultContext)results.get("response");
DocList docs = response.docs;
assertEquals(2, docs.size());
DocIterator it = docs.iterator();
assertTrue(it.hasNext());
assertEquals(0, it.nextDoc());
double score0 = it.score();
assertTrue(it.hasNext());
assertEquals(2, it.nextDoc());
double score2 = it.score();
assertFalse(it.hasNext());
// bf score boost for testid=0 only
assertTrue(score0 > score2);
List externalList = (List)((NamedList)results.get("xjoin5")).get("external");
NamedList hit0 = (NamedList)externalList.get(0);
assertEquals("0", hit0.get("joinId"));
NamedList doc0 = (NamedList)hit0.get("doc");
assertEquals("red", doc0.get("colour"));
assertEquals(10.5, doc0.get("value"));
}
开发者ID:flaxsearch,项目名称:BioSolr,代码行数:37,代码来源:TestSimple.java
示例15: setRescoredResults
import org.apache.solr.response.ResultContext; //导入依赖的package包/类
private void setRescoredResults(ResponseBuilder rb, TopDocs topDocs,
int offset, int len) {
DocListAndSet results = rb.getResults();
int totalHits = results.docList.matches();
int[] docs = new int[topDocs.scoreDocs.length];
float[] scores = new float[topDocs.scoreDocs.length];
for (int i = 0; i < topDocs.scoreDocs.length; i++) {
docs[i] = topDocs.scoreDocs[i].doc;
scores[i] = topDocs.scoreDocs[i].score;
}
results.docList = new DocSlice(offset, len, docs, scores, totalHits,
topDocs.getMaxScore());
ResultContext ctx = (ResultContext) rb.rsp.getValues().get("response");
ctx.docs = results.docList;
}
开发者ID:atware,项目名称:solr-leaning2rank,代码行数:16,代码来源:RankingComponent.java
示例16: write
import org.apache.solr.response.ResultContext; //导入依赖的package包/类
/**
* Here the writer creates its output.
*
* @param writer the character stream writer.
* @param request the current {@link SolrQueryRequest}
* @param response the output response.
* @throws IOException in case of I/O failure.
*/
@SuppressWarnings("rawtypes")
@Override
public void write(
final Writer writer,
final SolrQueryRequest request,
final SolrQueryResponse response) throws IOException {
// 1. Get a reference to values that compound the current response
final NamedList elements = response.getValues();
// 2. Use a StringBuilder to build the output
final StringBuilder builder = new StringBuilder("{")
.append("query:'")
.append(request.getParams().get(CommonParams.Q))
.append("',");
// 3. Get a reference to the object which hold the query result
final Object value = elements.getVal(1);
if (value instanceof ResultContext) {
final ResultContext context = (ResultContext) value;
// The ordered list (actually the page subset) of matched documents
final DocList ids = context.getDocList();
if (ids != null) {
final SolrIndexSearcher searcher = request.getSearcher();
final DocIterator iterator = ids.iterator();
builder.append("suggestions:[");
// 4. Iterate over documents
for (int i = 0; i < ids.size(); i++) {
// 5. For each document we need to get the corresponding "label" attribute
final Document document = searcher.doc(iterator.nextDoc(), FIELDS);
if (i > 0) { builder.append(","); }
// 6. Append the label value to writer output
builder
.append("'")
.append(((String) document.get("label")).replaceAll("'", "\\\\'").replaceAll("\"", "\\\\\""))
.append("'");
}
builder.append("]").append("}");
}
}
// 7. and finally write out the built character stream by means of output writer.
writer.write(builder.toString());
}
开发者ID:agazzarini,项目名称:as-full-text-search-server,代码行数:56,代码来源:CustomResponseWriter.java
示例17: write
import org.apache.solr.response.ResultContext; //导入依赖的package包/类
/**
* Here the writer creates its output.
*
* @param writer the character stream writer.
* @param request the current {@link SolrQueryRequest}
* @param response the output response.
* @throws IOException in case of I/O failure.
*/
@SuppressWarnings("rawtypes")
@Override
public void write(
final Writer writer,
final SolrQueryRequest request,
final SolrQueryResponse response) throws IOException {
// 1. Get a reference to values that compound the current response
final NamedList elements = response.getValues();
// 2. Use a StringBuilder to build the output
final StringBuilder builder = new StringBuilder("{")
.append("query:'")
.append(request.getParams().get(CommonParams.Q))
.append("',");
// 3. Get a reference to the object which hold the query result
final Object value = elements.getVal(1);
if (value instanceof ResultContext)
{
final ResultContext context = (ResultContext) value;
// The ordered list (actually the page subset) of matched documents
final DocList ids = context.docs;
if (ids != null)
{
final SolrIndexSearcher searcher = request.getSearcher();
final DocIterator iterator = ids.iterator();
builder.append("suggestions:[");
// 4. Iterate over documents
for (int i = 0; i < ids.size(); i++)
{
// 5. For each document we need to get the corresponding "label" attribute
final Document document = searcher.doc(iterator.nextDoc(), FIELDS);
if (i > 0) { builder.append(","); }
// 6. Append the label value to writer output
builder
.append("'")
.append(((String) document.get("label")).replaceAll("'", "\\\\'").replaceAll("\"", "\\\\\""))
.append("'");
}
builder.append("]").append("}");
}
}
// 7. and finally write out the built character stream by means of output writer.
writer.write(builder.toString());
}
开发者ID:agazzarini,项目名称:apache-solr-essentials,代码行数:59,代码来源:AutocompleteResponseWriter.java
示例18: howManyFound
import org.apache.solr.response.ResultContext; //导入依赖的package包/类
/**
* Returns the total count of matches associated with the given query response.
*
* @param qresponse the "response" portion of the {@link QueryResponse}.
* @return the total count of matches associated with the given query response.
*/
int howManyFound(final NamedList<?> qresponse) {
final ResultContext context = (ResultContext)qresponse.get(RESPONSE_KEY);
return context != null ? context.getDocList().size() : 0;
}
开发者ID:spaziocodice,项目名称:invisible-queries-request-handler,代码行数:11,代码来源:InvisibleQueriesRequestHandler.java
注:本文中的org.apache.solr.response.ResultContext类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论