2

I receive the following facets when I query :

"Field1": [
  {
    "Key": "Best Facet 1",
    "Value": 999
  },
  {
    "Key": "Best Facet 2",
    "Value": 999
  }
],
"Field2": [
  {
    "Key": "Second Best Facet 1",
    "Value": 421
  },
  {
    "Key": "Second Best Facet 2",
    "Value": 103
  }
]

Now I want to apply filter query (fq) on Field2 = "Second Best Facet 2"

The results I receive are

"Field1": [
  {
    "Key": "Best Facet 1",
    "Value": 103
  },
  {
    "Key": "Best Facet 2",
    "Value": 103
  }
],
"Field2": [
  {
    "Key": "Second Best Facet 1",
    "Value": 103
  },
  {
    "Key": "Second Best Facet 2",
    "Value": 103
  }
]

I need the facet counts to remain consistent and not be affected by the filter applied. I can't find any solutions to the problem.

1 Answer 1

4

You can tag your filters and tell Solr to ignore those filters when calculating the facet scores:

fq={!tag=dt}doctype:pdf&facet.field={!ex=dt}doctype

fq= applies the filter, but tags the filter with the tag dt, and by telling facet.field to exclude any filter tagged as dt, it will still calculate counts across the whole collection and not just the filtered values.

Filter exclusion is supported for all types of facets. Both the tag and ex local params may specify multiple values by separating them with commas.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.