我试图编写一个Elasticsearch查询,它将返回具有嵌套字段的元素。不过,我显然遇到了很多困难。我给这家字段映射通常看起来如下:筛选存在嵌套字段的Elaticsearch查询
{ "myType": { "properties": { "hello": { "type": "nested", "properties": { "foo": {"type": "string", "index": "not_analyzed"}, "bar": {"type": "string", "index": "not_analyzed"}, } } } } }
我的查询一般如下: { "query": { "filtered": { "filter": { "exists": { "field": "hello.foo" } } } } }
该查询返回0匹配的文件,即使我知道有匹配的文件。
我也尝试在nested
查询中使用exists
查询,但给出了有关nested
查询不支持exists
查询的错误消息。
我对Elasticsearch 2.3进行测试任何帮助将不胜感激!
哈哈,我正要后,我会找到我的答案从旧的博客文章(http://joelabrahamsson.com/elasticsearch-nested-mapping-和过滤器/)。但是这正是它所说的(在嵌套过滤器中使用另一个过滤器,然后使用exists过滤器)。我将编辑你的'term'过滤器作为'存在'过滤器并且标记你的答案是正确的!谢谢您的帮助! – user114241