jpountz commented on a change in pull request #612:
URL: https://github.com/apache/lucene/pull/612#discussion_r791530357
##########
File path:
lucene/core/src/java/org/apache/lucene/search/TotalHitCountCollector.java
##########
@@ -16,7 +16,12 @@
*/
package org.apache.lucene.search;
-/** Just counts the total number of hits. */
+/**
+ * Just counts the total number of hits. For cases when this is the only
collector used, {@link
+ * IndexSearcher#count(Query)} should be called instead of {@link
IndexSearcher#search(Query,
+ * Collector)} as the former is faster whenever the match can be returned
directly from the index
Review comment:
Did you mean s/match/count/?
```suggestion
* Collector)} as the former is faster whenever the count can be returned
directly from the index
```
##########
File path: lucene/core/src/test/org/apache/lucene/search/TestLRUQueryCache.java
##########
@@ -945,7 +945,7 @@ public void onUse(Query query) {
searcher.setQueryCache(queryCache);
searcher.setQueryCachingPolicy(policy);
- searcher.search(query.build(), new TotalHitCountCollector());
+ searcher.count(query.build());
Review comment:
I think this one should use TotalHitCountCollector too.
##########
File path: lucene/core/src/test/org/apache/lucene/search/TestLRUQueryCache.java
##########
@@ -1169,7 +1169,7 @@ public void testDetectMutatedQueries() throws IOException
{
searcher.setQueryCachingPolicy(ALWAYS_CACHE);
BadQuery query = new BadQuery();
- searcher.count(query);
+ searcher.search(query, new TotalHitCountCollector());
Review comment:
I think it makes the assumption that since BadQuery doesn't implement
Weight#count then it will interact with caching. My gut feeling is that it's
better to use TotalHitCountCollector which is more explicit.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]