Disable inner_hit fields from search api response

Is it possible to disable certain inner_hit fields in the response from the Search API. We have many hits and it is taking up unnecessary memory.

e.g we would like to ES to remove the commented out fields from the response below:

{
    "took": 82,
    "timed_out": false,
    "_shards": { "total": 10, "successful": 10, "skipped": 0, "failed": 0 },
    "hits": {
        "total": 1,
        "max_score": 1,
        "hits": [
            {
                "inner_hits": {
                    "foo": {
                        "hits": {
                            "total": 252,
                            "max_score": null,
                            "hits": [
                                {
                                    // "_index": "cactus",
                                    // "_type": "_doc",
                                    // "_id": "xxx",
                                    "_nested": { "field": "measurement", "offset": 203 },
                                    // "_score": null,
                                    // "sort": [1565740800000, "1DAA3DB2-30B0-4A8C-90EC-DE0A3DAB9A53"],
                                    "fields": {
                                        "measurement.id": ["1DAA3DB2-30B0-4A8C-90EC-DE0A3DAB9A53"]
                                    }
                                }
                            ]
                        }
                    }
                }
            }
        ]
    }
}
1 Like

I found the solution here: https://www.elastic.co/guide/en/elasticsearch/reference/6.8/common-options.html#common-options-response-filtering

You can try filtering using something like:

?filter_path=hits.hits.inner_hits.*.hits.hits.*.*

I am not sure if it has performance implications.

1 Like

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