http://stackoverflow.com/questions/15543308/elasticsearch-filtering-by-the-size-of-a-field-that-is-an-array
注意现在的missing关键字已经被取消了,请使用exists
https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-exists-query.html
官方文档中讲的是对普通属性的Exists查询,对于nested属性,相关查询请这样写:
search_body = { "query": { "nested": { "path": "tags_list", "query": { "exists": {"field": "tags_list.count"} } } }, "size": 2 }当我们使用脚本进行查询时python代码可以这样写:
search_body = { "query": { "bool": { "filter": { "script": { "script": "doc['alias'].values.length > 1" } } } }, "size": 2 }