searchsolrsolrjfacetsolr7

Solr count mismatch between facet and filter query


I am running solr 7.7.2 and I am trying to apply facet on a particular field

"display-classification_en_string_mv" (type="string" indexed="true" stored="false" multiValued="true")

The problem is when I try to apply facets on this field, with

acet=true&facet.field={!ex%3Dfkdisplay-classification}display-classification_en_string_mv&facet.mincount=1&facet.limit=10&facet.sort=count, 

The actual facet count I get for a variant of this field "maxi dress" is 100 as shown below.

facet count for value "maxi dress" under field is 100

Now when I try to add a filterquery (fq) like this

fq={!tag%3Dfkdisplay-classification}+display-classification_en_string_mv:"Maxi+Dress"

the actual count increases to 101.

after filter query count increases to 101

One thing to note is I am using a collapse query to group documents having same value in a field of type="string" indexed="true" stored="true".

This count mismatch happens only when the collapse query is applied, and without the collapsing in place, the count remains same in both cases.

Please let me know if I am missing something or any error in implementation which might lead to this.


Solution

  • Apparently, the collapse query selects one of the documents in the group as a leader and selects it for counting facets, and in one of the group, the leader which was getting selected didn't have the field considered for facets.