kaivalnp opened a new pull request, #13202:
URL: https://github.com/apache/lucene/pull/13202

   ### Description
   
   #927 added timeout support to 
[`IndexSearcher#search`](https://github.com/apache/lucene/blob/75e1ebc4501733a6a9857858b3fd9c30304234d0/lucene/core/src/java/org/apache/lucene/search/IndexSearcher.java#L680)
 where we wrap a scorer in a 
[`TimeLimitingBulkScorer`](https://github.com/apache/lucene/blob/main/lucene/core/src/java/org/apache/lucene/search/TimeLimitingBulkScorer.java)
 which periodically checks whether a query timed out while collecting docs in 
fixed 
[chunks](https://github.com/apache/lucene/blob/main/lucene/core/src/java/org/apache/lucene/search/TimeLimitingBulkScorer.java#L33-L35)
   
   However as #11677 points out, this does not apply to query rewrites -- an 
important use case being vector searches 
([`AbstractKnnVectorQuery`](https://github.com/apache/lucene/blob/main/lucene/core/src/java/org/apache/lucene/search/AbstractKnnVectorQuery.java)),
 where the bulk of computations (HNSW graph searches) happen in 
[`#rewrite`](https://github.com/apache/lucene/blob/75e1ebc4501733a6a9857858b3fd9c30304234d0/lucene/core/src/java/org/apache/lucene/search/AbstractKnnVectorQuery.java#L68)
   
   If we had set a timeout, and HNSW searches turned out too expensive -- we 
would not return results even after the search completes (because the timeout 
is [checked before attempting to score 
docs](https://github.com/apache/lucene/blob/main/lucene/core/src/java/org/apache/lucene/search/TimeLimitingBulkScorer.java#L79-L82)
 -- at which point we have all possible results, but they aren't returned)
   
   In this PR, we're wrapping the `KnnCollector` in another one which 
additionally checks for `QueryTimeout#shouldExit` in the 
`KnnCollector#earlyTerminated` function. If this timeout is hit, we immediately 
return empty results
   
   Also extended this to exact searches, where we check for a timeout before 
scoring each document


-- 
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: issues-unsubscr...@lucene.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org
For additional commands, e-mail: issues-h...@lucene.apache.org

Reply via email to