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


Java TotalHitCountCollector.getTotalHits方法代码示例

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


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

示例1: olderDocumentsExists

import org.apache.lucene.search.TotalHitCountCollector; //导入方法依赖的package包/类
/**
 * Searches the index, if older documents exists. Updates the solr query response.
 *
 * @param req - the solr query request information
 * @param rsp - the solr query response information
 * @return true if the hit count is greater zero, otherwise false
 * @throws SyntaxError, IOException if bad things happen
 */
private boolean olderDocumentsExists(String queryString, SolrQueryRequest req, SolrQueryResponse rsp) throws SyntaxError, IOException {
    String defType = req.getParams().get(QueryParsing.DEFTYPE, QParserPlugin.DEFAULT_QTYPE);

    QParser queryParser = QParser.getParser(queryString, defType, req);
    Query query = queryParser.getQuery();

    TotalHitCountCollector totalHitCountCollector = new TotalHitCountCollector();
    req.getSearcher().search(query, totalHitCountCollector);

    rsp.add("query", String.format("%s:[* TO NOW-%s]", queryField, timeSeriesAge));
    rsp.add("queryTechnical", queryString);
    rsp.add("removedDocuments", totalHitCountCollector.getTotalHits());

    return totalHitCountCollector.getTotalHits() != 0;
}
 
开发者ID:ChronixDB,项目名称:chronix.server,代码行数:24,代码来源:ChronixRetentionHandler.java

示例2: numDocs

import org.apache.lucene.search.TotalHitCountCollector; //导入方法依赖的package包/类
/**
 * Returns the number of documents that match both <code>a</code> and <code>b</code>.
 * <p>
 * This method is cache-aware and may check as well as modify the cache.
 *
 * @return the number of documents in the intersection between <code>a</code> and <code>b</code>.
 * @throws IOException If there is a low-level I/O error.
 */
public int numDocs(Query a, DocSet b) throws IOException {
  if (filterCache != null) {
    // Negative query if absolute value different from original
    Query absQ = QueryUtils.getAbs(a);
    DocSet positiveA = getPositiveDocSet(absQ);
    return a==absQ ? b.intersectionSize(positiveA) : b.andNotSize(positiveA);
  } else {
    // If there isn't a cache, then do a single filtered query
    // NOTE: we cannot use FilteredQuery, because BitDocSet assumes it will never 
    // have deleted documents, but UninvertedField's doNegative has sets with deleted docs
    TotalHitCountCollector collector = new TotalHitCountCollector();
    BooleanQuery bq = new BooleanQuery();
    bq.add(QueryUtils.makeQueryable(a), BooleanClause.Occur.MUST);
    bq.add(new ConstantScoreQuery(b.getTopFilter()), BooleanClause.Occur.MUST);
    super.search(bq, null, collector);
    return collector.getTotalHits();
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:27,代码来源:SolrIndexSearcher.java

示例3: countIndexedNodes

import org.apache.lucene.search.TotalHitCountCollector; //导入方法依赖的package包/类
@Override
public int countIndexedNodes( long nodeId, Object propertyValue )
{
    Query nodeIdQuery = new TermQuery( documentLogic.newTermForChangeOrRemove( nodeId ) );
    Query valueQuery = documentLogic.newSeekQuery( propertyValue );
    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();
        searcher.search( nodeIdAndValueQuery.build(), collector );
        // A <label,propertyKeyId,nodeId> tuple should only match at most a single propertyValue
        return collector.getTotalHits();
    }
    catch ( IOException e )
    {
        throw new RuntimeException( e );
    }
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-lucene5-index,代码行数:21,代码来源:LuceneIndexAccessorReader.java

示例4: count

import org.apache.lucene.search.TotalHitCountCollector; //导入方法依赖的package包/类
private int count(Query query) {
       TotalHitCountCollector collector = new TotalHitCountCollector();
	try {
		searcher.search(query, collector);
	} catch (IOException e) {
		throw new RuntimeException(e);
	}		
	return collector.getTotalHits();
}
 
开发者ID:jmccrae,项目名称:naisc,代码行数:10,代码来源:Search.java

示例5: createCounter

import org.apache.lucene.search.TotalHitCountCollector; //导入方法依赖的package包/类
private AdCategoryWithCounterVO createCounter(final IndexSearcher searcher, final Query query, final Filters baseFilters, final AdCategory adCategory, final AdCategoryWithCounterVO parent, final int level) throws IOException {
    // Run with filters based on the current category
    Filters filters = (Filters) baseFilters.clone();
    filters.addTerms("category", adCategory.getId());
    TotalHitCountCollector collector = new TotalHitCountCollector();
    searcher.search(query, filters, collector);
    int totalCount = collector.getTotalHits();
    AdCategoryWithCounterVO counter = new AdCategoryWithCounterVO(adCategory.getId(), adCategory.getName(), level, totalCount, parent);
    // Repeat recursively for each child
    for (AdCategory childCategory : adCategory.getChildren()) {
        AdCategoryWithCounterVO childCounter = createCounter(searcher, query, baseFilters, childCategory, counter, level + 1);
        counter.addChild(childCounter);
    }
    return counter;
}
 
开发者ID:mateli,项目名称:OpenCyclos,代码行数:16,代码来源:AdDAOImpl.java

示例6: countDocsWithClass

import org.apache.lucene.search.TotalHitCountCollector; //导入方法依赖的package包/类
private int countDocsWithClass() throws IOException {
  int docCount = MultiFields.getTerms(this.atomicReader, this.classFieldName).getDocCount();
  if (docCount == -1) { // in case codec doesn't support getDocCount
    TotalHitCountCollector totalHitCountCollector = new TotalHitCountCollector();
    BooleanQuery q = new BooleanQuery();
    q.add(new BooleanClause(new WildcardQuery(new Term(classFieldName, String.valueOf(WildcardQuery.WILDCARD_STRING))), BooleanClause.Occur.MUST));
    if (query != null) {
      q.add(query, BooleanClause.Occur.MUST);
    }
    indexSearcher.search(q,
        totalHitCountCollector);
    docCount = totalHitCountCollector.getTotalHits();
  }
  return docCount;
}
 
开发者ID:europeana,项目名称:search,代码行数:16,代码来源:SimpleNaiveBayesClassifier.java

示例7: getWordFreqForClass

import org.apache.lucene.search.TotalHitCountCollector; //导入方法依赖的package包/类
private int getWordFreqForClass(String word, BytesRef c) throws IOException {
  BooleanQuery booleanQuery = new BooleanQuery();
  BooleanQuery subQuery = new BooleanQuery();
  for (String textFieldName : textFieldNames) {
   subQuery.add(new BooleanClause(new TermQuery(new Term(textFieldName, word)), BooleanClause.Occur.SHOULD));
  }
  booleanQuery.add(new BooleanClause(subQuery, BooleanClause.Occur.MUST));
  booleanQuery.add(new BooleanClause(new TermQuery(new Term(classFieldName, c)), BooleanClause.Occur.MUST));
  if (query != null) {
    booleanQuery.add(query, BooleanClause.Occur.MUST);
  }
  TotalHitCountCollector totalHitCountCollector = new TotalHitCountCollector();
  indexSearcher.search(booleanQuery, totalHitCountCollector);
  return totalHitCountCollector.getTotalHits();
}
 
开发者ID:europeana,项目名称:search,代码行数:16,代码来源:SimpleNaiveBayesClassifier.java

示例8: searchHits

import org.apache.lucene.search.TotalHitCountCollector; //导入方法依赖的package包/类
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);
    }
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:16,代码来源:LuceneSearchIndex.java

示例9: countDocsWithClass

import org.apache.lucene.search.TotalHitCountCollector; //导入方法依赖的package包/类
private int countDocsWithClass() throws IOException {
  int docCount = MultiFields.getTerms(this.atomicReader, this.classFieldName).getDocCount();
  if (docCount == -1) { // in case codec doesn't support getDocCount
    TotalHitCountCollector totalHitCountCollector = new TotalHitCountCollector();
    indexSearcher.search(new WildcardQuery(new Term(classFieldName, String.valueOf(WildcardQuery.WILDCARD_STRING))),
        totalHitCountCollector);
    docCount = totalHitCountCollector.getTotalHits();
  }
  return docCount;
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:11,代码来源:SimpleNaiveBayesClassifier.java

示例10: getWordFreqForClass

import org.apache.lucene.search.TotalHitCountCollector; //导入方法依赖的package包/类
private int getWordFreqForClass(String word, BytesRef c) throws IOException {
  BooleanQuery booleanQuery = new BooleanQuery();
  booleanQuery.add(new BooleanClause(new TermQuery(new Term(textFieldName, word)), BooleanClause.Occur.MUST));
  booleanQuery.add(new BooleanClause(new TermQuery(new Term(classFieldName, c)), BooleanClause.Occur.MUST));
  TotalHitCountCollector totalHitCountCollector = new TotalHitCountCollector();
  indexSearcher.search(booleanQuery, totalHitCountCollector);
  return totalHitCountCollector.getTotalHits();
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:9,代码来源:SimpleNaiveBayesClassifier.java

示例11: getTotalDocs

import org.apache.lucene.search.TotalHitCountCollector; //导入方法依赖的package包/类
private static int getTotalDocs(NodeContext context) throws IOException {
    TotalHitCountCollector collector = new TotalHitCountCollector();
    context.req.getSearcher().search(new MatchAllDocsQuery(), collector);
    return collector.getTotalHits();
}
 
开发者ID:careerbuilder,项目名称:semantic-knowledge-graph,代码行数:6,代码来源:ScoreNormalizer.java

示例12: simpleDocCount

import org.apache.lucene.search.TotalHitCountCollector; //导入方法依赖的package包/类
/**
 * Simple utility method to get document counts for a given query.
 * This uses TotalHitCounter.
 *
 * @param query  query
 * @param reader reader
 * @return number of docs with a hit
 * @throws java.io.IOException if there is an exception from teh searcher
 */
public int simpleDocCount(Query query, IndexReader reader) throws IOException {
  IndexSearcher searcher = new IndexSearcher(reader);
  TotalHitCountCollector collector = new TotalHitCountCollector();
  searcher.search(query, collector);
  return collector.getTotalHits();
}
 
开发者ID:tballison,项目名称:lucene-addons,代码行数:16,代码来源:SimpleTargetCounter.java


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