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


Java SolrPluginUtils.docListToSolrDocumentList方法代码示例

本文整理汇总了Java中org.apache.solr.util.SolrPluginUtils.docListToSolrDocumentList方法的典型用法代码示例。如果您正苦于以下问题:Java SolrPluginUtils.docListToSolrDocumentList方法的具体用法?Java SolrPluginUtils.docListToSolrDocumentList怎么用?Java SolrPluginUtils.docListToSolrDocumentList使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.solr.util.SolrPluginUtils的用法示例。


在下文中一共展示了SolrPluginUtils.docListToSolrDocumentList方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: checkEngine

import org.apache.solr.util.SolrPluginUtils; //导入方法依赖的package包/类
private List<NamedList<Object>> checkEngine(CarrotClusteringEngine engine, int expectedNumDocs,
                         int expectedNumClusters, Query query, SolrParams clusteringParams) throws IOException {
  // Get all documents to cluster
  RefCounted<SolrIndexSearcher> ref = h.getCore().getSearcher();

  DocList docList;
  try {
    SolrIndexSearcher searcher = ref.get();
    docList = searcher.getDocList(query, (Query) null, new Sort(), 0,
            numberOfDocs);
    assertEquals("docList size", expectedNumDocs, docList.matches());

    ModifiableSolrParams solrParams = new ModifiableSolrParams();
    solrParams.add(clusteringParams);

    // Perform clustering
    LocalSolrQueryRequest req = new LocalSolrQueryRequest(h.getCore(), solrParams);
    Map<SolrDocument,Integer> docIds = new HashMap<>(docList.size());
    SolrDocumentList solrDocList = SolrPluginUtils.docListToSolrDocumentList( docList, searcher, engine.getFieldsToLoad(req), docIds );

    @SuppressWarnings("unchecked")
    List<NamedList<Object>> results = (List<NamedList<Object>>) engine.cluster(query, solrDocList, docIds, req);
    req.close();
    assertEquals("number of clusters: " + results, expectedNumClusters, results.size());
    checkClusters(results, false);
    return results;
  } finally {
    ref.decref();
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:31,代码来源:CarrotClusteringEngineTest.java

示例2: cluster

import org.apache.solr.util.SolrPluginUtils; //导入方法依赖的package包/类
@Override
@Deprecated
public Object cluster(Query query, DocList docList, SolrQueryRequest sreq) {
  SolrIndexSearcher searcher = sreq.getSearcher();
  SolrDocumentList solrDocList;
  try {
    Map<SolrDocument,Integer> docIds = new HashMap<SolrDocument, Integer>(docList.size());
    solrDocList = SolrPluginUtils.docListToSolrDocumentList( docList, searcher, getFieldsToLoad(sreq), docIds );
    return cluster(query, solrDocList, docIds, sreq);
  } catch (IOException e) {
    throw new SolrException(ErrorCode.SERVER_ERROR, e);
  }
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:14,代码来源:CarrotClusteringEngine.java

示例3: checkEngine

import org.apache.solr.util.SolrPluginUtils; //导入方法依赖的package包/类
private List<NamedList<Object>> checkEngine(CarrotClusteringEngine engine, int expectedNumDocs,
                         int expectedNumClusters, Query query, SolrParams clusteringParams) throws IOException {
  // Get all documents to cluster
  RefCounted<SolrIndexSearcher> ref = h.getCore().getSearcher();

  DocList docList;
  try {
    SolrIndexSearcher searcher = ref.get();
    docList = searcher.getDocList(query, (Query) null, new Sort(), 0,
            numberOfDocs);
    assertEquals("docList size", expectedNumDocs, docList.matches());

    ModifiableSolrParams solrParams = new ModifiableSolrParams();
    solrParams.add(clusteringParams);

    // Perform clustering
    LocalSolrQueryRequest req = new LocalSolrQueryRequest(h.getCore(), solrParams);
    Map<SolrDocument,Integer> docIds = new HashMap<SolrDocument, Integer>(docList.size());
    SolrDocumentList solrDocList = SolrPluginUtils.docListToSolrDocumentList( docList, searcher, engine.getFieldsToLoad(req), docIds );

    @SuppressWarnings("unchecked")
    List<NamedList<Object>> results = (List<NamedList<Object>>) engine.cluster(query, solrDocList, docIds, req);
    req.close();
    assertEquals("number of clusters: " + results, expectedNumClusters, results.size());
    checkClusters(results, false);
    return results;
  } finally {
    ref.decref();
  }
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:31,代码来源:CarrotClusteringEngineTest.java

示例4: getSolrDocumentList

import org.apache.solr.util.SolrPluginUtils; //导入方法依赖的package包/类
public SolrDocumentList getSolrDocumentList(DocList docList, SolrQueryRequest sreq,
    Map<SolrDocument, Integer> docIds) throws IOException{
  return SolrPluginUtils.docListToSolrDocumentList(
      docList, sreq.getSearcher(), getFieldsToLoad(sreq), docIds);
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:6,代码来源:SearchClusteringEngine.java

示例5: testDocListConversion

import org.apache.solr.util.SolrPluginUtils; //导入方法依赖的package包/类
@Test
public void testDocListConversion() throws Exception {
  assertU("", adoc("id", "3234", "val_i", "1", 
                   "val_dynamic", "quick red fox"));
  assertU("", adoc("id", "3235", "val_i", "1", 
                   "val_dynamic", "quick green fox"));
  assertU("", adoc("id", "3236", "val_i", "1", 
                   "val_dynamic", "quick brown fox"));
  assertU("", commit());

  RefCounted<SolrIndexSearcher> holder = h.getCore().getSearcher();
  try {
    SolrIndexSearcher srchr = holder.get();
    SolrIndexSearcher.QueryResult qr = new SolrIndexSearcher.QueryResult();
    SolrIndexSearcher.QueryCommand cmd = new SolrIndexSearcher.QueryCommand();
    cmd.setQuery(new MatchAllDocsQuery());
    cmd.setLen(10);
    qr = srchr.search(qr, cmd);
    
    DocList docs = qr.getDocList();
    assertEquals("wrong docs size", 3, docs.size());
    Set<String> fields = new HashSet<String>();
    fields.add("val_dynamic");
    fields.add("dynamic_val");
    fields.add("range_facet_l"); // copied from id
    
    SolrDocumentList list = SolrPluginUtils.docListToSolrDocumentList(docs, srchr, fields, null);
    assertEquals("wrong list Size", docs.size(), list.size());
    for (SolrDocument document : list) {
      
      assertTrue("unexpected field", ! document.containsKey("val_i"));
      assertTrue("unexpected id field", ! document.containsKey("id"));

      assertTrue("original field", document.containsKey("val_dynamic"));
      assertTrue("dyn copy field", document.containsKey("dynamic_val"));
      assertTrue("copy field", document.containsKey("range_facet_l"));
      
      assertNotNull("original field null", document.get("val_dynamic"));
      assertNotNull("dyn copy field null", document.get("dynamic_val"));
      assertNotNull("copy field null", document.get("range_facet_l"));
    }
  } finally {
    if (null != holder) holder.decref();
  }
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:46,代码来源:SolrPluginUtilsTest.java

示例6: docListToSolrDocumentList

import org.apache.solr.util.SolrPluginUtils; //导入方法依赖的package包/类
/**
 * Converts the docs into a solr document list.
 *
 * @param docs     The {@link org.apache.solr.search.DocList} to convert
 * @param searcher The {@link org.apache.solr.search.SolrIndexSearcher} to use to load the docs from the Lucene index
 * @param fields   The names of the Fields to load
 * @param ids      A map to store the ids of the docs
 * @return the docs as solr document list.
 * @throws IOException if bad things happen.
 */
@Override
public SolrDocumentList docListToSolrDocumentList(DocList docs, SolrIndexSearcher searcher, Set<String> fields, Map<SolrDocument, Integer> ids) throws IOException {
    return SolrPluginUtils.docListToSolrDocumentList(docs, searcher, fields, ids);
}
 
开发者ID:ChronixDB,项目名称:chronix.server,代码行数:15,代码来源:SolrDocListProvider.java


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