Hi, Adrien Grand Could we check the result after BKD.intersect() inner the PointInSetQuery.scorer(), if the result.build.iterator() the first next doc is already NO_MORE_DOCS ? We need not to build scorer with new ConstantScoreScorer() , just return null. In this way, the BooleanQuery for AND can terminate early and the subsequent clauses should not evaluate to build scorer to waste extra compute resource.
This terminate more early on PointInSetQuery can be good at a number match leading clause of boolean query search mode with a high percent requests whose number match hits is empty. hacker win7 hackersw...@gmail.com > On Sep 28, 2020, at 21:06, Adrien Grand <jpou...@gmail.com> wrote: > > What are you storing in your points? If you are storing numbers, I wonder if > a better approach to this problem might be to start leveraging > IndexOrDocValuesQuery and scorerSupplier() for point-in-set queries like we > did for range queries. > > The approach you suggested would help in some cases, but I'm a bit unhappy > that it would be quite fragile, e.g. SubQuery1 AND SubQuery2 might become > faster as we could save evaluating matches of SubQuery2 but SubQuery2 AND > SubQuery1 would still be slow. > > On Mon, Sep 28, 2020 at 5:02 AM hacker win7 <hackersw...@gmail.com > <mailto:hackersw...@gmail.com>> wrote: > Hi Lucene developers, > > In Lucene-7.7.0, I find that in `PointInSetQuery.createWeight()`, and in the > method `scorer()` after `values.intersect()`, if the `result.bitSet` is null, > then the `result.build()` would use `concat()` to generate a Buffer and the > length is 1. And the element of array is `NO_MORE_DOCS`. > > Why not return null in the method `scorer()` if `result.bitSet` is null ? > > In the following case: > > SubQuery1 AND SubQuery2 AND SubQuery3 …... > > BooleanWeight.scorerSupplier() -> > > the first subScorer of query is PointInSetQuery -> > > scorer() -> > > after intersect if result.bitSet is null, there is no specific point value at > all then return null -> > > > This will terminate early in the BooleanWeight.scoreSupplier() because > subScore is null and the boolean clause is required > > The following SubQuery2, SubQuery3, SubQuery4 …. Need not to call > scorerSupplier() to build scorer > > > hacker win7 > hackersw...@gmail.com <mailto:hackersw...@gmail.com> > > > > > > -- > Adrien