File tree Expand file tree Collapse file tree 2 files changed +10
-6
lines changed
lucene/core/src/java/org/apache/lucene/search Expand file tree Collapse file tree 2 files changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -440,7 +440,11 @@ public ScoreMode scoreMode() {
440
440
}
441
441
}
442
442
443
- /** Count how many documents match the given query. */
443
+ /**
444
+ * Count how many documents match the given query. May be faster than counting number of hits by
445
+ * collecting all matches, as the number of hits is retrieved from the index statistics when
446
+ * possible.
447
+ */
444
448
public int count (Query query ) throws IOException {
445
449
query = rewrite (query );
446
450
final Weight weight = createWeight (query , ScoreMode .COMPLETE_NO_SCORES , 1 );
Original file line number Diff line number Diff line change @@ -178,13 +178,13 @@ public BulkScorer bulkScorer(LeafReaderContext context) throws IOException {
178
178
* Counts the number of live documents that match a given {@link Weight#parentQuery} in a leaf.
179
179
*
180
180
* <p>The default implementation returns -1 for every query. This indicates that the count could
181
- * not be computed in O(1) time.
181
+ * not be computed in sub-linear time.
182
182
*
183
- * <p>Specific query classes should override it to provide other accurate O(1) implementations
184
- * (that actually return the count). Look at {@link MatchAllDocsQuery#createWeight(IndexSearcher,
185
- * ScoreMode, float)} for an example
183
+ * <p>Specific query classes should override it to provide other accurate sub-linear
184
+ * implementations (that actually return the count). Look at {@link
185
+ * MatchAllDocsQuery#createWeight(IndexSearcher, ScoreMode, float)} for an example
186
186
*
187
- * <p>We use this property of the function to to count hits in {@link IndexSearcher#count(Query)}.
187
+ * <p>We use this property of the function to count hits in {@link IndexSearcher#count(Query)}.
188
188
*
189
189
* @param context the {@link org.apache.lucene.index.LeafReaderContext} for which to return the
190
190
* count.
You can’t perform that action at this time.
0 commit comments