热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

org.apache.lucene.search.TotalHitCountCollector.getTotalHits()方法的使用及代码示例

本文整理了Java中org.apache.lucene.search.TotalHitCountCollector.getTotalHits()方法的一些代码示例,展示了TotalHitCountCo

本文整理了Java中org.apache.lucene.search.TotalHitCountCollector.getTotalHits()方法的一些代码示例,展示了TotalHitCountCollector.getTotalHits()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TotalHitCountCollector.getTotalHits()方法的具体详情如下:
包路径:org.apache.lucene.search.TotalHitCountCollector
类名称:TotalHitCountCollector
方法名:getTotalHits

TotalHitCountCollector.getTotalHits介绍

[英]Returns how many hits matched the search.
[中]返回与搜索匹配的点击数。

代码示例

代码示例来源:origin: org.apache.lucene/lucene-core

@Override
public Integer reduce(Collection collectors) throws IOException {
int total = 0;
for (TotalHitCountCollector collector : collectors) {
total += collector.getTotalHits();
}
return total;
}

代码示例来源:origin: neo4j/neo4j

@Override
public long countIndexedNodes( long nodeId, int[] propertyKeyIds, Value... propertyValues )
{
try
{
String[] propertyKeys = new String[propertyKeyIds.length];
for ( int i = 0; i {
propertyKeys[i] = propertyKeyTokenHolder.getTokenById( propertyKeyIds[i] ).name();
}
Query query = LuceneFulltextDocumentStructure.newCountNodeEntriesQuery( nodeId, propertyKeys, propertyValues );
TotalHitCountCollector collector = new TotalHitCountCollector();
getIndexSearcher().search( query, collector );
return collector.getTotalHits();
}
catch ( Exception e )
{
throw new RuntimeException( e );
}
}
}

代码示例来源:origin: neo4j/neo4j

@Override
public long countIndexedNodes( long nodeId, int[] propertyKeyIds, Value... propertyValues )
{
Query nodeIdQuery = new TermQuery( LuceneDocumentStructure.newTermForChangeOrRemove( nodeId ) );
Query valueQuery = LuceneDocumentStructure.newSeekQuery( propertyValues );
BooleanQuery.Builder nodeIdAndValueQuery = new BooleanQuery.Builder().setDisableCoord( true );
nodeIdAndValueQuery.add( nodeIdQuery, BooleanClause.Occur.MUST );
nodeIdAndValueQuery.add( valueQuery, BooleanClause.Occur.MUST );
try
{
TotalHitCountCollector collector = new TotalHitCountCollector();
getIndexSearcher().search( nodeIdAndValueQuery.build(), collector );
// A tuple should only match at most a single propertyValue
return collector.getTotalHits();
}
catch ( IOException e )
{
throw new RuntimeException( e );
}
}

代码示例来源:origin: querydsl/querydsl

private long innerCount() {
try {
final int maxDoc = searcher.maxDoc();
if (maxDoc == 0) {
return 0;
}
TotalHitCountCollector collector = new TotalHitCountCollector();
searcher.search(createQuery(), getFilter(), collector);
return collector.getTotalHits();
} catch (IOException e) {
throw new QueryException(e);
} catch (IllegalArgumentException e) {
throw new QueryException(e);
}
}

代码示例来源:origin: querydsl/querydsl

private long innerCount() {
try {
final int maxDoc = searcher.getIndexReader().maxDoc();
if (maxDoc == 0) {
return 0;
}
TotalHitCountCollector collector = new TotalHitCountCollector();
searcher.search(createQuery(), getFilter(), collector);
return collector.getTotalHits();
} catch (IOException e) {
throw new QueryException(e);
} catch (IllegalArgumentException e) {
throw new QueryException(e);
}
}

代码示例来源:origin: querydsl/querydsl

private long innerCount() {
try {
final int maxDoc = searcher.getIndexReader().maxDoc();
if (maxDoc == 0) {
return 0;
}
TotalHitCountCollector collector = new TotalHitCountCollector();
searcher.search(createQuery(), getFilter(), collector);
return collector.getTotalHits();
} catch (IOException e) {
throw new QueryException(e);
} catch (IllegalArgumentException e) {
throw new QueryException(e);
}
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.lucene

@Override
public Integer reduce(Collection collectors) throws IOException {
int total = 0;
for (TotalHitCountCollector collector : collectors) {
total += collector.getTotalHits();
}
return total;
}

代码示例来源:origin: org.infinispan/infinispan-embedded-query

@Override
public Integer reduce(Collection collectors) throws IOException {
int total = 0;
for (TotalHitCountCollector collector : collectors) {
total += collector.getTotalHits();
}
return total;
}

代码示例来源:origin: harbby/presto-connectors

@Override
public Integer reduce(Collection collectors) throws IOException {
int total = 0;
for (TotalHitCountCollector collector : collectors) {
total += collector.getTotalHits();
}
return total;
}

代码示例来源:origin: hibernate/hibernate-search

public long getTotalHits() {
return totalHitCountCollector.getTotalHits();
}

代码示例来源:origin: com.twitter.elephantbird/elephant-bird-lucene

@Override
protected Iterator search(IndexSearcher searcher, Query query) throws IOException {
TotalHitCountCollector collector = new TotalHitCountCollector();
searcher.search(query, collector);
return ImmutableList.of(new IntWritable(collector.getTotalHits())).iterator();
}
}

代码示例来源:origin: stackoverflow.com

Query query = parser1.parser("+sport +category:a")
TotalHitCountCollector collector = new TotalHitCountCollector();
search.search(query, collector);
ctr = collector.getTotalHits();
query = parser1.parser("+sport +category:b")
collector = new TotalHitCountCollector();
search.search(query, collector);
ctr1 = collector.getTotalHits();

代码示例来源:origin: com.qwazr/qwazr-search

@Override
public final Integer getTotalHits() {
if (totalHitCountCollector != null)
return totalHitCountCollector.getTotalHits();
if (topDocsCollector != null)
return topDocsCollector.getTotalHits();
return 0;
}

代码示例来源:origin: harbby/presto-connectors

@Override
public TopDocs call() throws Exception {
return new TopDocs(totalHitCountCollector.getTotalHits(), Lucene.EMPTY_SCORE_DOCS, 0);
}
};

代码示例来源:origin: com.qwazr/qwazr-search

@Override
public final Integer getTotalHits() {
if (queryCollectorsList == null || queryCollectorsList.isEmpty())
return 0;
int totalHits = 0;
for (QueryCollectorsClassic queryCollectors : queryCollectorsList) {
if (queryCollectors.totalHitCountCollector != null)
totalHits += queryCollectors.totalHitCountCollector.getTotalHits();
else if (queryCollectors.topDocsCollector != null)
totalHits += queryCollectors.topDocsCollector.getTotalHits();
}
return totalHits;
}

代码示例来源:origin: arago/rike

public long count(Query q) {
TotalHitCountCollector collector = new TotalHitCountCollector();
try {
IndexSearcher s = getSearcher();
s.search(q, collector);
return collector.getTotalHits();
} catch (IOException ex) {
throw new RuntimeException(ex);
}
}

代码示例来源:origin: com.atlassian.bonnie/atlassian-bonnie

public int searchCount(final Query query, final Filter filter)
{
final TotalHitCountCollector totalHitCountCollector = new TotalHitCountCollector();
luceneConnection.withSearch(new ILuceneConnection.SearcherAction()
{
public void perform(IndexSearcher searcher) throws IOException
{
searcher.search(query, filter, totalHitCountCollector);
}
});
return totalHitCountCollector.getTotalHits();
}

代码示例来源:origin: org.kie.uberfire/kie-uberfire-metadata-backend-lucene

private int searchHits( final Query query,
final ClusterSegment... clusterSegments ) {
final IndexSearcher index = indexManager.getIndexSearcher( clusterSegments );
try {
final TotalHitCountCollector collector = new TotalHitCountCollector();
index.search( query, collector );
return collector.getTotalHits();
} catch ( final Exception ex ) {
throw new RuntimeException( "Error during Query!", ex );
} finally {
indexManager.release( index );
}
}

代码示例来源:origin: org.elasticsearch/elasticsearch

TotalHitCountCollector totalHitCountCollector = new TotalHitCountCollector();
intersect(weight, innerHitQueryWeight, totalHitCountCollector, ctx);
result[i] = new TopDocs(totalHitCountCollector.getTotalHits(), Lucene.EMPTY_SCORE_DOCS, 0);
} else {
int topN = Math.min(from() + size(), context.searcher().getIndexReader().maxDoc());

代码示例来源:origin: com.b2international.snowowl/com.b2international.snowowl.snomed.api.impl

private int getHitCount(final Query query) throws IOException {
IndexSearcher searcher = null;
try {
searcher = manager.acquire();
final TotalHitCountCollector collector = new TotalHitCountCollector();
searcher.search(query, collector);
return collector.getTotalHits();
} finally {
if (null != searcher) {
manager.release(searcher);
}
}
}

推荐阅读
author-avatar
徐涛
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有