Skip to content

Commit

Permalink
Use the proper collector for hits counting
Browse files Browse the repository at this point in the history
  • Loading branch information
knutwalker authored and MishaDemianenko committed Dec 5, 2015
1 parent 663c643 commit 0934095
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.TermQuery;
import org.apache.lucene.search.TotalHitCountCollector;
import org.apache.lucene.util.BytesRef;

import java.io.Closeable;
Expand Down Expand Up @@ -139,9 +140,10 @@ public int countIndexedNodes( long nodeId, Object propertyValue )
nodeIdAndValueQuery.add( valueQuery, BooleanClause.Occur.MUST );
try
{
Hits hits = new Hits( searcher, nodeIdAndValueQuery, null );
TotalHitCountCollector collector = new TotalHitCountCollector();
searcher.search( nodeIdAndValueQuery, collector );
// A <label,propertyKeyId,nodeId> tuple should only match at most a single propertyValue
return hits.length();
return collector.getTotalHits();
}
catch ( IOException e )
{
Expand Down

0 comments on commit 0934095

Please sign in to comment.