On Thu, Dec 19, 2024 at 4:51 PM Mingchun Zhao <mingchun.zha...@gmail.com> wrote:
> Hi Mikhail, > > ``` > return new BooleanQuery.Builder() > .add(scoreQuery, Occur.MUST) > .add(filterQuery, Occur.FILTER) > .build(); > ``` > > So, I have two questions here: > > Question 1: Does this imply that the index search with the q parameter is > executed first, followed by the index search with the fq parameter? > Here are two answers. Order of calling BQ.Builder.add() doesn't decide the order of execution, as well as occur. BooleanQuery lazily executes intersection dynamically and adjusts to actual values, with many conditions and spec cases. However, if you check SolrIndexSearcher.getProcessedFilter() you notice that it executes filters eagerly and cache them (both up to parameters). So, here the filterQuery in most cases will be bitset (or other) ie materialized filter. > Question 2: Regardless of the processing order of index searches for the q > parameter and the fq parameter, I believe that the overall search > performance remains unaffected. Is this understanding correct please? > It depends on relative selectivity (number of matched documents) of q and fq. In an edge case deferring filters with cost>100 might get significant gain. > > > here we go > > > > https://github.com/apache/solr/blob/61609b1b599b839952fe6a8f0e163254caddd472/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java#L1889 > > This was such a helpful hint. Thank you very much. > > Regards, > Mingchun > -- Sincerely yours Mikhail Khludnev