1

I want create a nested date range facet that has buckets by year, month, and day.

A query like this for a hard-coded date range (e.g. between 2020 to 2022)

{
  "q": "*:*",
  "start": 0,
  "rows": 0,
  "json.facet": {
    "year": {
      "type": "range",
      "field": "archiveDate",
      "sort": "archiveDate asc",
      "start": "2020-01-01T00:00:00Z",
      "end": "2023-01-01T00:00:00Z",
      "gap": "/YEAR+1YEAR",
      "facet": {
        "month": {
          "type": "range",
          "field": "archiveDate",
          "sort": "archiveDate asc",
          "start": "2020-01-01T00:00:00Z",
          "end": "2023-01-01T00:00:00Z",
          "gap": "/MONTH+1MONTH",
          "facet": {
            "day": {
              "type": "range",
              "field": "archiveDate",
              "sort": "archiveDate asc",
              "start": "2020-01-01T00:00:00Z",
              "end": "2023-01-01T00:00:00Z",
              "gap": "/DAY+1DAY"
            }
          }
        }
      }
    }
  }
}

works, but it takes a while, and returns way too many buckets for the "month" and "day" facets - most of them zero, because they are outside of the parent range.

Is there a way to restrict the "start" and "end" of the nested facets to their respective parents?

The Solr version in question is 7.2.

Tomalak
  • 332,285
  • 67
  • 532
  • 628
  • If I'm reading the Solr source code right, this seems to be impossible. At least there don't seem to be any "magic" values that would cause range facets to become context-sensitive. Oh well. – Tomalak Mar 02 '22 at 15:53

0 Answers0