I'm new to Elasticsearch so forgive me if I don't know the lingo.
I have this mapping with a nested object Command
"Command": { "type": "nested", "include_in_parent": true, "properties": { "Src": { "type": "string", "index": "not_analyzed" }, "Dst": { "type": "string", "index": "not_analyzed" }, "CommandName": { "type": "string", "index": "not_analyzed" }, "Time": { "type": "string", "index": "not_analyzed" }, "Action": { "type": "string", "index": "not_analyzed" }, } }, "OsInfo": { "type": "string", "index": "not_analyzed" }, "OsRev": { "type": "string", "index": "not_analyzed" }, "OsUID": { "type": "string", "index": "not_analyzed" }, "Osname": { "type": "string", "index": "not_analyzed" },
I have a query
{ "query": { "filtered": { "query": { "bool": { "must": [ {"nested": { "path": "Command", "query": { "bool": { "must": [ {"match": {"Command.Action": "Create"}} ] } }, "inner_hits": { "size": 20, "_source": ["Action"] }, "score_mode": "sum" } } ] } } } } }
which gives me 20 inner hits (with only the Action field) sorted from most inner hits to least per outer hit
My question is how do i filter the outer hits based on the amount of inner hits?
For example:
I want all the outer docs that have exactly 4 inner hits from Command.Action:Create
Thanks!
Jeremy