本文整理汇总了Java中org.apache.lucene.search.grouping.AbstractAllGroupHeadsCollector类的典型用法代码示例。如果您正苦于以下问题:Java AbstractAllGroupHeadsCollector类的具体用法?Java AbstractAllGroupHeadsCollector怎么用?Java AbstractAllGroupHeadsCollector使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AbstractAllGroupHeadsCollector类属于org.apache.lucene.search.grouping包,在下文中一共展示了AbstractAllGroupHeadsCollector类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: create
import org.apache.lucene.search.grouping.AbstractAllGroupHeadsCollector; //导入依赖的package包/类
/**
* Creates an <code>AbstractAllGroupHeadsCollector</code> instance based on the supplied arguments.
* This factory method decides with implementation is best suited.
*
* @param groupField The field to group by
* @param sortWithinGroup The sort within each group
* @param initialSize The initial allocation size of the internal int set and group list which should roughly match
* the total number of expected unique groups. Be aware that the heap usage is
* 4 bytes * initialSize.
* @return an <code>AbstractAllGroupHeadsCollector</code> instance based on the supplied arguments
*/
public static AbstractAllGroupHeadsCollector<?> create(String groupField, Sort sortWithinGroup, int initialSize) {
boolean sortAllScore = true;
boolean sortAllFieldValue = true;
for (SortField sortField : sortWithinGroup.getSort()) {
if (sortField.getType() == SortField.Type.SCORE) {
sortAllFieldValue = false;
} else if (needGeneralImpl(sortField)) {
return new GeneralAllGroupHeadsCollector(groupField, sortWithinGroup);
} else {
sortAllScore = false;
}
}
if (sortAllScore) {
return new ScoreAllGroupHeadsCollector(groupField, sortWithinGroup, initialSize);
} else if (sortAllFieldValue) {
return new OrdAllGroupHeadsCollector(groupField, sortWithinGroup, initialSize);
} else {
return new OrdScoreAllGroupHeadsCollector(groupField, sortWithinGroup, initialSize);
}
}
开发者ID:europeana,项目名称:search,代码行数:34,代码来源:TermAllGroupHeadsCollector.java
示例2: testTermAllGroupHeadsCollector
import org.apache.lucene.search.grouping.AbstractAllGroupHeadsCollector; //导入依赖的package包/类
@Test
public void testTermAllGroupHeadsCollector() throws Exception {
String groupField = "title";
Sort sortWithinGroup = new Sort();
searcherManager.maybeRefresh();
IndexSearcher searcher = searcherManager.acquire();
// Render groupsResult... Note that the groupValue of each GroupDocs will be null, so if you need to present this value you'll have to separately retrieve it (for example using stored fields, FieldCache, etc.).
//Another collector is the TermAllGroupHeadsCollector that can be used to retrieve all most relevant documents per group. Also known as group heads. This can be useful in situations when one wants to compute group based facets / statistics on the complete query result. The collector can be executed during the first or second phase. This collector can also be used with the GroupingSearch convenience utility, but when if one only wants to compute the most relevant documents per group it is better to just use the collector as done here below.
AbstractAllGroupHeadsCollector collector = TermAllGroupHeadsCollector.create(groupField, sortWithinGroup);
searcher.search(new TermQuery(new Term("title", "Lucene")), collector);
// Return all group heads as int array
int[] groupHeadsArray = collector.retrieveGroupHeads();
// Return all group heads as FixedBitSet.
int maxDoc = searcher.getIndexReader().maxDoc();
FixedBitSet groupHeadsBitSet = collector.retrieveGroupHeads(maxDoc);
}
开发者ID:russ168,项目名称:thrift-transport,代码行数:21,代码来源:LuceneTests.java
示例3: computeGroupedDocSet
import org.apache.lucene.search.grouping.AbstractAllGroupHeadsCollector; //导入依赖的package包/类
private DocSet computeGroupedDocSet(Query query, ProcessedFilter filter, List<Collector> collectors) throws IOException {
Command firstCommand = commands.get(0);
AbstractAllGroupHeadsCollector termAllGroupHeadsCollector =
TermAllGroupHeadsCollector.create(firstCommand.getKey(), firstCommand.getSortWithinGroup());
if (collectors.isEmpty()) {
searchWithTimeLimiter(query, filter, termAllGroupHeadsCollector);
} else {
collectors.add(termAllGroupHeadsCollector);
searchWithTimeLimiter(query, filter, MultiCollector.wrap(collectors.toArray(new Collector[collectors.size()])));
}
return new BitDocSet(termAllGroupHeadsCollector.retrieveGroupHeads(searcher.maxDoc()));
}
开发者ID:europeana,项目名称:search,代码行数:14,代码来源:CommandHandler.java
示例4: computeGroupedDocSet
import org.apache.lucene.search.grouping.AbstractAllGroupHeadsCollector; //导入依赖的package包/类
private DocSet computeGroupedDocSet(Query query, ProcessedFilter filter, List<Collector> collectors) throws IOException {
Command firstCommand = commands.get(0);
AbstractAllGroupHeadsCollector termAllGroupHeadsCollector =
TermAllGroupHeadsCollector.create(firstCommand.getKey(), firstCommand.getSortWithinGroup());
if (collectors.isEmpty()) {
searchWithTimeLimiter(query, filter, termAllGroupHeadsCollector);
} else {
collectors.add(termAllGroupHeadsCollector);
searchWithTimeLimiter(query, filter, MultiCollector.wrap(collectors.toArray(new Collector[collectors.size()])));
}
int maxDoc = searcher.maxDoc();
long[] bits = termAllGroupHeadsCollector.retrieveGroupHeads(maxDoc).getBits();
return new BitDocSet(new OpenBitSet(bits, bits.length));
}
开发者ID:pkarmstr,项目名称:NYBC,代码行数:16,代码来源:CommandHandler.java
示例5: createAllGroupCollector
import org.apache.lucene.search.grouping.AbstractAllGroupHeadsCollector; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public AbstractAllGroupHeadsCollector<?> createAllGroupCollector() throws IOException {
Sort sortWithinGroup = groupSort != null ? groupSort : new Sort();
return TermAllGroupHeadsCollector.create(groupBy, sortWithinGroup);
}
开发者ID:europeana,项目名称:search,代码行数:9,代码来源:Grouping.java
注:本文中的org.apache.lucene.search.grouping.AbstractAllGroupHeadsCollector类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论