Search code examples
solrfull-text-searchaggregationfacet

Faceting before collapse in Solr


I am using CollapseQueryParser Plugin in Solr to collapse results across one common field.

Quoting the official Solr Documentation -

This parser collapses the result set to a single document per group before it forwards the result set to the rest of the search components. So all downstream components (faceting, highlighting, etc.) will work with the collapsed result set.

There are multiple facet fields in the query, and for one particular facet, I need to do the faceting or aggregation before the collapse happens and as usual for others. I tried excluding it with a tag and using collapse.facet=facet.before, but these didn't work.

Is there any way to do this in Solr? I am using Solr-7.7.2.

Thanks in advance!


Solution

  • As mentioned in the comments, I found a way to handle this. Posting this for someone who might encounter this in future.

    I had to tag the collapse query seperately and then use that tag wherever i needed exclusion as shown below.

    While collpsing -

    fq={!tag%3DcollapseTag}{!collapse+field%3Dcollapse_field+nullPolicy%3Dignore+cache%3Dfalse}

    And while faceting -

    facet.field={!ex%3Dfksize,collapseTag}size_string_mv