Facet ElasticSearch on list of dict (Python)

47 Views Asked by At

Given

Data in index looks like

{
  "entity_tags": [
    {
      "tags": [
        "two",
        "three"
      ],
      "tag_data_type": "multitextselect",
      "tag_group_name": "one 3"
    },
    {
      "tags": [
        "new1"
      ],
      "tag_data_type": "textselect",
      "tag_group_name": "one"
    },
    {
      "tags": [
        "10"
      ],
      "tag_data_type": "counter",
      "tag_group_name": "new"
    }
  ],
  "class": "A"
}

I need to write a Elasticsearch query (facet) in python such that output will return ( Need to return all possible values)

  1. class: [A], # as class contains A option only
  2. new:[10] # new contains10 option only
  3. one:[new1] # one contains new & new1 option only
  4. one 3:[three, two] # one 3 contains two & three option only

For a list of dict (here entity_tags ) it should return all tag_group_name values with possible tags values

Note: Above data is a sample document in ElasticSearch I need to return all possible values that are returned in response to support dynamic filters

0

There are 0 best solutions below