Skip to content

Commit e3b2efe

Browse files
javannajpountz
authored andcommitted
Improve Weight#count and IndexSearcher#count javadocs (#625)
1 parent 9340fb7 commit e3b2efe

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

lucene/core/src/java/org/apache/lucene/search/IndexSearcher.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,11 @@ public ScoreMode scoreMode() {
440440
}
441441
}
442442

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+
*/
444448
public int count(Query query) throws IOException {
445449
query = rewrite(query);
446450
final Weight weight = createWeight(query, ScoreMode.COMPLETE_NO_SCORES, 1);

lucene/core/src/java/org/apache/lucene/search/Weight.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -178,13 +178,13 @@ public BulkScorer bulkScorer(LeafReaderContext context) throws IOException {
178178
* Counts the number of live documents that match a given {@link Weight#parentQuery} in a leaf.
179179
*
180180
* <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.
182182
*
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
186186
*
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)}.
188188
*
189189
* @param context the {@link org.apache.lucene.index.LeafReaderContext} for which to return the
190190
* count.

0 commit comments

Comments
 (0)