本文整理汇总了Java中org.apache.lucene.search.MultiCollector.wrap方法的典型用法代码示例。如果您正苦于以下问题:Java MultiCollector.wrap方法的具体用法?Java MultiCollector.wrap怎么用?Java MultiCollector.wrap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.lucene.search.MultiCollector
的用法示例。
在下文中一共展示了MultiCollector.wrap方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: computeDocSet
import org.apache.lucene.search.MultiCollector; //导入方法依赖的package包/类
private DocSet computeDocSet(Query query, ProcessedFilter filter, List<Collector> collectors) throws IOException {
int maxDoc = searcher.maxDoc();
DocSetCollector docSetCollector;
if (collectors.isEmpty()) {
docSetCollector = new DocSetCollector(maxDoc >> 6, maxDoc);
} else {
Collector wrappedCollectors = MultiCollector.wrap(collectors.toArray(new Collector[collectors.size()]));
docSetCollector = new DocSetDelegateCollector(maxDoc >> 6, maxDoc, wrappedCollectors);
}
searchWithTimeLimiter(query, filter, docSetCollector);
return docSetCollector.getDocSet();
}
示例2: testAggregateSearchResultItem
import org.apache.lucene.search.MultiCollector; //导入方法依赖的package包/类
/**
* Test method for {@link com.fuerve.villageelder.actions.results.SearchResult#aggregate(com.fuerve.villageelder.actions.results.SearchResultItem)}.
*/
@Test
public final void testAggregateSearchResultItem() throws Exception {
Directory indexDirectoryExpected = new RAMDirectory();
Directory taxonomyDirectoryExpected = new RAMDirectory();
buildDummyIndex(indexDirectoryExpected, taxonomyDirectoryExpected);
IndexReader reader = DirectoryReader.open(indexDirectoryExpected);
IndexSearcher searcher = new IndexSearcher(reader);
TaxonomyReader taxo = new DirectoryTaxonomyReader(taxonomyDirectoryExpected);
QueryParser parser =
new SearchQueryParser(
Lucene.LUCENE_VERSION,
Lucene.DEFAULT_QUERY_FIELD,
Lucene.getPerFieldAnalyzer()
);
TopFieldCollector indexCollector = getDummyCollector();
FacetsCollector facetsCollector = getDummyFacetsCollector((DirectoryReader) reader, taxo);
Collector collector = MultiCollector.wrap(indexCollector, facetsCollector);
searcher.search(parser.parse("Revision:5*"), collector);
facetsCollector.getFacetResults();
SearchResult target = new SearchResult();
target.aggregate(new SearchResultItem(indexCollector.topDocs(), facetsCollector.getFacetResults()));
assertEquals(2, target.getTopDocs().totalHits);
assertEquals(1, target.getFacetResults().size());
}
示例3: testSearchResultItem
import org.apache.lucene.search.MultiCollector; //导入方法依赖的package包/类
/**
* Test method for {@link com.fuerve.villageelder.actions.results.SearchResultItem#SearchResultItem(org.apache.lucene.search.TopDocs, java.util.List)}.
*/
@Test
public final void testSearchResultItem() throws Exception {
Directory indexDirectoryExpected = new RAMDirectory();
Directory taxonomyDirectoryExpected = new RAMDirectory();
buildDummyIndex(indexDirectoryExpected, taxonomyDirectoryExpected);
IndexReader reader = DirectoryReader.open(indexDirectoryExpected);
IndexSearcher searcher = new IndexSearcher(reader);
TaxonomyReader taxo = new DirectoryTaxonomyReader(taxonomyDirectoryExpected);
QueryParser parser =
new SearchQueryParser(
Lucene.LUCENE_VERSION,
Lucene.DEFAULT_QUERY_FIELD,
Lucene.getPerFieldAnalyzer()
);
TopFieldCollector indexCollector = getDummyCollector();
FacetsCollector facetsCollector = getDummyFacetsCollector((DirectoryReader) reader, taxo);
Collector collector = MultiCollector.wrap(indexCollector, facetsCollector);
searcher.search(parser.parse("Revision:5*"), collector);
facetsCollector.getFacetResults();
SearchResultItem target = new SearchResultItem(indexCollector.topDocs(), facetsCollector.getFacetResults());
assertEquals(2, target.getTopDocs().totalHits);
assertEquals(1, target.getFacetResults().size());
}
示例4: wrap
import org.apache.lucene.search.MultiCollector; //导入方法依赖的package包/类
public void wrap(Collector collector) {
wrappedCollector = MultiCollector.wrap(collector, wrappedCollector);
}
示例5: testSearchCollector
import org.apache.lucene.search.MultiCollector; //导入方法依赖的package包/类
/**
* Test method for {@link com.fuerve.villageelder.search.Searcher#search(org.apache.lucene.search.Collector)}.
*/
@SuppressWarnings("unused")
@Test
public final void testSearchCollector() throws Exception {
// Gather declared fields.
Field indexDirectoryField = Searcher.class.getDeclaredField("indexDirectory");
Field taxonomyDirectoryField = Searcher.class.getDeclaredField("taxonomyDirectory");
Field indexDirectoryNameField = Searcher.class.getDeclaredField("indexDirectoryName");
Field taxonomyDirectoryNameField = Searcher.class.getDeclaredField("taxonomyDirectoryName");
Field stringDirectoriesField = Searcher.class.getDeclaredField("stringDirectories");
Field initializedField = Searcher.class.getDeclaredField("initialized");
Field searchField = Searcher.class.getDeclaredField("search");
Field indexReaderField = Searcher.class.getDeclaredField("indexReader");
Field indexSearcherField = Searcher.class.getDeclaredField("indexSearcher");
Field taxonomyReaderField = Searcher.class.getDeclaredField("taxonomyReader");
indexDirectoryField.setAccessible(true);
taxonomyDirectoryField.setAccessible(true);
indexDirectoryNameField.setAccessible(true);
taxonomyDirectoryNameField.setAccessible(true);
stringDirectoriesField.setAccessible(true);
initializedField.setAccessible(true);
searchField.setAccessible(true);
indexReaderField.setAccessible(true);
indexSearcherField.setAccessible(true);
taxonomyReaderField.setAccessible(true);
// Setup
Directory indexDirectoryExpected = new RAMDirectory();
Directory taxonomyDirectoryExpected = new RAMDirectory();
buildDummyIndex(indexDirectoryExpected, taxonomyDirectoryExpected);
Searcher target = new Searcher(indexDirectoryExpected, taxonomyDirectoryExpected);
target.initializeSearch();
// Gather field values.
Directory indexDirectoryActual = (Directory) indexDirectoryField.get(target);
Directory taxonomyDirectoryActual = (Directory) taxonomyDirectoryField.get(target);
String indexDirectoryNameActual = (String) indexDirectoryNameField.get(target);
String taxonomyDirectoryNameActual = (String) taxonomyDirectoryNameField.get(target);
boolean stringDirectoriesActual = stringDirectoriesField.getBoolean(target);
boolean initializedActual = initializedField.getBoolean(target);
Search searchFieldActual = (Search) searchField.get(target);
IndexReader indexReaderActual = (IndexReader) indexReaderField.get(target);
IndexSearcher indexSearcherActual = (IndexSearcher) indexSearcherField.get(target);
TaxonomyReader taxonomyReaderActual = (TaxonomyReader) taxonomyReaderField.get(target);
// Create the Collector to be passed in and execute a search to populate it.
final TopFieldCollector collector = getDummyCollector();
final FacetsCollector facetsCollector =
getDummyFacetsCollector((DirectoryReader) indexReaderActual, taxonomyReaderActual);
final Collector testCollector = MultiCollector.wrap(collector, facetsCollector);
target.createSearch("Revision:5*");
target.search(testCollector);
// Test
assertEquals(true, initializedActual);
assertEquals(2, collector.topDocs().totalHits);
}