Filter by size of nested object


I have an index with nested objects (flags).

Example document:

"title": "Sample title",
"flags": [
{"read"}, {"marked"}

I want to query all documents which have more than one flag.
How can this be done?

I tried to filter by flags.size, but get the error: No field found for [flags] in mapping with types

"query": {
"bool": {
"filter": {
"script": {
"script": "if (doc['flags'].size > 1) {return (true)}"

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