Getting the facets info using search API facets

I have data in the format

{
     field1:"data",
     field2 :{
                       innerField1 : "data2",
                      innerField2: "data3"
                 }
}

i want to implement the facets with search API, to get the different innerField2 and their count.

{
  "query": {
    "bool": {
      "must": [
        {
          // query
        }
      ]
    }
  },
  "facets": {
    "innerField2": [
      {
        "type": "value",
        "name": "innerField2",
        "sort": { "count": "desc" },
        "size": 10
      }
    ]
  }
}

i want to know how to pass the facets properly to get the facets info.

as am getting the error

"error": {
                    "root_cause": [
                        {
                            "type": "parsing_exception",
                            "reason": "Unknown key for a START_OBJECT in [facets].",
                            "line": 1,
                            "col": 133
                        }
                    ],
                    "type": "parsing_exception",
                    "reason": "Unknown key for a START_OBJECT in [facets].",
                    "line": 1,
                    "col": 133
                },
                "status": 4

document following: Search API facets | App Search documentation [8.10] | Elastic

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.