Good evening,

I am using facet json api to query aggregation data, and I don't care about
the returned documents themselves. One of the use cases I want to employ is
tagging filter queries for fields, and then exclude those filters when
faceting. My problem is, however, that in those cases where the filter has
0 matches, the facets aren't calculated at all.

I'm using dataset I found at
https://www.raspberry.nl/2010/12/29/solr-test-dataset/ . To illustrate --
this is an an example when filter doesn't filter out everything (working as
expected):

Request:
{
  "query": "*:*",
  "facet": {
    "latitude_f": {
      "type": "range",
      "start": -90,
      "facet": {
        "population": "sum(population_i)"
      },
      "domain": {
        "excludeTags": "latitude_f"
      },
      "gap": 10,
      "end": -70,
      "field": "latitude_f"
    }
  },
  "limit": 0,
  "filter": [
    "{!tag=latitude_f}latitude_f:[-80.0 TO -70.0]"
  ]
}

Response:

{
  "facets": {
    "count": 1,
    "latitude_f": {
      "buckets": [
        {
          "val": -90,
          "count": 0
        },
        {
          "val": -80,
          "count": 1,
          "population": 1258
        }
      ]
    }
  }
}


Example when filter filters everything out:

Request is the same, except the filter field value is

  "filter": [
    "{!tag=latitude_f}latitude_f:[-90.0 TO -80.0]"
  ]

and response is

 "facets":{
    "count":0}

. I'm returned no facets whatsoever. However I'd expect the response to be
the same as and for the first request, since the only one filter is used,
and is excluded in faceting.

Is this a bug? What are the workarounds for such problem?

Reply via email to