Question

I am trying to filter my facets on multiple values, it works on single one:

"facet_filter": {
    "term": {
      "function":"value_1"
    }
}

but what I am trying to do is to filter on multiple values ideally with boolean control(and/or)

"facet_filter": {
    "term": {
      "function": [
        "value_1",
        "value_2"
      ]
    }
}

Is there an easy way to do this ? I found similar question but actually it does not explain what list(id) is. Any clues ? filtering facets in elasticsearch

Was it helpful?

Solution

Solution to my problem was as suggested to use terms instead of term.

Posted full request below as I could not find so might be beneficial to others who are searching for same answer.

{
  "query": {
    "bool": {
      "must": [
        {
          "term": {
            "syslog.log_key": "time"
          }
        }
      ],
      "must_not": [],
      "should": []
    }
  },
  "size": 0,
  "facets": {
    "tag": {
      "terms_stats": {
        "key_field": "function",
        "value_field": "log_value"
      },
      "facet_filter": {
        "terms": {
          "function": [
            "query_parser",
            "term_highlighter"
          ]
        }
      }
    }
  }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top