当前位置: 首页>>代码示例>>Java>>正文


Java ResultContext类代码示例

本文整理汇总了Java中org.apache.solr.response.ResultContext的典型用法代码示例。如果您正苦于以下问题:Java ResultContext类的具体用法?Java ResultContext怎么用?Java ResultContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ResultContext类属于org.apache.solr.response包,在下文中一共展示了ResultContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


注:本文中的org.apache.solr.response.ResultContext类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。