# Getting the facets info using search API facets

**URL:** <https://discuss.elastic.co/t/getting-the-facets-info-using-search-api-facets/344289>\
**Category:** Elasticsearch\
**Created:** [October 3, 2023, 7:35am UTC](https://discuss.elastic.co/t/getting-the-facets-info-using-search-api-facets/344289 "2023-10-03T07:35:41Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aswanth\_Parambath](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aswanth_parambath/32/126214_2.png) [@Aswanth\_Parambath](https://discuss.elastic.co/u/Aswanth_Parambath)\
**Post date:** [October 3, 2023, 7:35am UTC](https://discuss.elastic.co/t/getting-the-facets-info-using-search-api-facets/344289/1 "2023-10-03T07:35:41Z")

</div>

I have data in the format

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

```

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

```auto
{
  "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

```auto
"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](https://www.elastic.co/guide/en/app-search/current/facets.html)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [October 31, 2023, 7:36am UTC](https://discuss.elastic.co/t/getting-the-facets-info-using-search-api-facets/344289/2 "2023-10-31T07:36:21Z")

</div>

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