kotman12 opened a new issue, #17004:
URL: https://github.com/apache/lucene/issues/17004

   ### Description
   
   When encoding a _batch_ of documents the monitor effectively
   flattens the terms so you lose information about which document(s)
   a term belongs to. Unfortunately, this can work against the
   main optimization within the multi-pass term filtered presearcher
   (arguably the best of the Presearcher implementations)
   
   To give an example consider the query `(apple AND pear)` with `df=field`. The
   multi-pass pre-searcher may expand this to `{field_0:apple, field_1:pear}`.
   When a document batch comes in `[{field:apple}, {field:pear}]` the terms
   get flattened into
   `(field_0:apple OR field_0:pear) AND (field_1:apple OR field_1:pear)`
   which matches the indexed query but is a false positive as the query
   doesn't match any of the documents in the batch. Now had you sent
   both documents individually, i.e. `(field_0:apple) AND (field_1:apple)`
   and `(field_0:pear) AND (field_1:pear)`,
   the pre-search would have correctly filtered them out. So batching is
   often worse from pre-filtering perspective.
   
   Note that this does not affect regular term-filtered presearcher
   as it always will index one of the branches in the conjunction,
   i.e `field:apple`. Which means one of those documents in the hypothetical
   batch would be false-positive _anyway_ had you sent them individually.
   This means the false positive candidate query would be run the same amount
   of times in either case (batched or unbatched).
   
   I think the Presearcher should expose an option to pre-search
   with each document individually but match against the full batch to
   capture the efficiency gain on both ends. The Monitor can decide
   which Presearcher API to invoke depending on what kind of
   Presearcher it is and/or with what a power-user specifies. It could
   also be based on batch heuristics, i.e. how correlated the documents
   are. If the documents are very correlated the negative effect is
   less noticeable.


-- 
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]

Reply via email to