Daniele,

The filter cache contains unsorted lists of docs; an entry ultimately needs
to be sorted to what the user wants.  The score in particular requires
actually running the query, at which point there isn't a point in using the
filter cache.  Well sort of; I could imagine a hybrid to visit only the
matching docs but that would add complexity.

~ David Smiley
Apache Lucene/Solr Search Developer
http://www.linkedin.com/in/davidwsmiley


On Mon, Jan 3, 2022 at 2:30 PM Daniele Antuzi <[email protected]>
wrote:

> Hi Mikhail,
> Thanks for your reply.
> Probably I wasn't clear enough, actually, in the piece of code I pointed
> out
> <https://github.com/apache/solr/blob/c2db3a943e665cfb39e9ea53640be40cf2c09fbc/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java#L1387-L1398>,
> the searcher decides whether to use (or not use) the filterCache by setting
> the boolean *useFilterCache*.
>
> The searcher will use the filterCache in the search only if
>
>    - the filterCache exists
>    - AND the flags *GET_SCORES* and *NO_CHECK_FILTERCACHE* are not set
>    - AND the parameter *useFilterForSortedQuery* is true (by default is
>    false and I don't really understand why)
>    - AND the sort is not null
>    - AND none of the sort clause contains the score
>
> If I don't mistaken, if the sort is null the resultset is sorted by the
> score.
> So, if the resultset is sorted implicitly or explicitly by score, the
> searcher does not use the filterCache. Does everyone know why?
>
>
>
> Il giorno lun 3 gen 2022 alle ore 16:50 Mikhail Khludnev <[email protected]>
> ha scritto:
>
>> Hi, Adrien. Thanks for forwarding this.
>> Daniele, you pointed to the code which bypasses Lucene searching and just
>> sorts cached docset.
>> Applying filter before searching is done by getProcessedFilter()
>> https://github.com/apache/solr/blob/c2db3a943e665cfb39e9ea53640be40cf2c09fbc/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java#L956
>>
>> Happy New Year!
>>
>> On Mon, Jan 3, 2022 at 5:12 PM Adrien Grand <[email protected]> wrote:
>>
>>> Hi Daniele,
>>>
>>> This is the Lucene dev list, I'm redirecting your question to
>>> [email protected].
>>>
>>> On Fri, Dec 31, 2021 at 5:35 PM Daniele Antuzi <[email protected]>
>>> wrote:
>>> >
>>> > Hi,
>>> > I was taking a look at the Solr searcher to see how the filterCache is
>>> used:
>>> https://github.com/apache/solr/blob/c2db3a943e665cfb39e9ea53640be40cf2c09fbc/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java#L1379-L1398
>>> > Reading the code, it turned out that the filterCache is not used if
>>> the sort contains the score or if we don't have any score specified (by
>>> default, it sorts by score).
>>> > As far as I know, the filterCache contains an unordered set of
>>> documents so the sort must be calculated after the application of the
>>> filter query.
>>> > Then, also the score should be computed after the filter query to have
>>> a smaller set of documents.
>>> > That being said, I don't understand why Solr does not use the
>>> filterCache if the score is somehow involved in the sort.
>>> > In theory, it can
>>> >
>>> > apply the filter query reducing the number of result
>>> > computes the score
>>> > sort the results
>>> >
>>> > Am I missing something?
>>> >
>>> > Happy new year,
>>> > Daniele
>>> >
>>>
>>>
>>> --
>>> Adrien
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [email protected]
>>> For additional commands, e-mail: [email protected]
>>>
>>>
>>
>> --
>> Sincerely yours
>> Mikhail Khludnev
>>
>

Reply via email to