Skip to content

Instantly share code, notes, and snippets.

@hkulekci
Last active Jul 14, 2022
Embed
What would you like to do?
Elasticsearch Nested Array Object Size Aggregation
# images field type is nested
GET products/_search
{
  "track_total_hits": true, 
  "size": 0, 
  "aggs": {
    "counts": {
      "terms": {
        "script": "params['_source']['images'].size()",
        "size": 10
      }
    }
  }
}
@ar-hosseinkhani
Copy link

ar-hosseinkhani commented Aug 31, 2021

after many searches on different websites, finally I found this piece of code and It works! Thanks Mr. Hkuleckci

@hkulekci
Copy link
Author

hkulekci commented Aug 31, 2021

@ar-hosseinkhani welcome 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment