It's been a little while since I looked at this section of the code. But
what I believe is going on is that the queryResultCache has kicked in which
will give you the DocList (the top N docs that match query/filters/sort)
back immediately. But faceting requires a DocSet which is a bitset of all
docs that match the query. The DocSet is not cached in this scenario, so it
needs to be regenerated, which means re-running the query/collapse. So I
believe your instincts are correct. This same issue gets worse if you have
facets that need refinement. In this scenario the DocSet is needed on the
first and second pass and is not cached, the so query/collapse need to be
run twice for facets.

The fix for this would be to start caching the DocSets needed for faceting.




Joel Bernstein
http://joelsolr.blogspot.com/

On Fri, Feb 10, 2017 at 1:29 PM, Ronald K. Braun <ronbr...@gmail.com> wrote:

> I'm experimenting with field collapsing in solrcloud 6.2.1 and have this
> set of request parameters against a collection:
>
> /default?indent=on&q=*:*&wt=json&fq={!collapse+field=groupid}
>
> My default handler is just defaults:
>
>     <requestHandler name="/default" class="solr.SearchHandler">
>         <lst name="defaults">
>             <str name="echoParams">explicit</str>
>         </lst>
>     </requestHandler>
>
> The first query runs about 600ms, then subsequent repeats of the same query
> are 0-5ms for qTime, which I interpret to mean that the query is cached
> after the first hit.  All as expected.
>
> However, if I enable facets without actually requesting a facet:
>
> /default?indent=on&q=*:*&wt=json&fq={!collapse+field=groupid}&facet=true
>
> then every submission of the query runs at ~600ms.  I interpret this to
> mean that caching is somehow defeated when facet processing is set.  Facets
> are empty as expected:
>
>     facet_counts": {
>       "facet_queries": { },
>       "facet_fields": { },
>       "facet_ranges": { },
>       "facet_intervals": { },
>       "facet_heatmaps": { }
>     }
>
> If I remove the collapse directive
>
> /default?indent=on&q=*:*&wt=json&facet=true
>
> qTimes are back down to 0 after the initial query whether or not faceting
> is requested.
>
> Is this expected behaviour or am I missing some supporting configuration
> for proper field collapsing?
>
> Thanks!
>
> Ron
>

Reply via email to