内部命中不能使用嵌套过滤器? [英] Inner hits not working with nested filter?
问题描述
我刚刚升级到Elastic Search 1.5.0,到目前为止,我无法使 inner_hits 使用嵌套过滤器,虽然它可以正常使用嵌套查询。
假设我想在电影对象中检索内部嵌套对象 actors 。
当我运行以下嵌套查询:
语法1
GET my_index / movie / _search
{
query:{
filtered:{
query:{match_all :{}},
filter:{
nested:{
path:actors,
query:{
:{
actors.id:12345
}
},
inner_hits:{}
}
}
}
}
}
=>我得到inner_hits文件记录这里,这是很好的。
但是当我尝试使用嵌套过滤器:
语法2
GET my_index / movie / _search
{
query:{
filtered:{
query:{match_all {}}
filter:{
nested:{
path:actors,
filter:{
:{
actors.id:12345
}
},
inner_hits:{}
}
}
}
}
}
=>我得到以下解析错误
QueryParsingException [[my_index] [嵌套]需要'查询'或
'过滤器'字段]
(当我删除inner_hits时,最后一个查询工作正常 - 除了我没有得到内部命中... )
我使用的语法有什么问题,还是没有实现嵌套过滤器的inner_hits?
提前感谢
编辑3-30-2015
它适用于 @mdewit (谢谢!)
下面提供的语法语法3
GET my_index / movie / _search
$即使这个语法不符合
{
查询:{
nested:{
path:actors,
query:{
filtered:{
filter {
term:{actors.id:12345}
}
}
},
inner_hits:{}
}
}
}
query-dsl-nested-filter.htmlrel =nofollow noreferrer>嵌套过滤器文档
=>我还是不明白有什么问题语法2.对于我来说似乎是一个ES错误。
编辑04-22-2015:修正了在ES 1.5.1中,见我的评论如下
解决方案错误修复在ElasticSearch 1.5.1中,如这里
所以这个语法工作(并且正常工作)
GET my_index / movie / _search
{
query:{
filtered:{
query:{match_all:{}},
filter:{
nested:{
path:actors,
filter :{
term:{
actors.id:12345
}
},
inner_hits:{}
}
}
}
}
}
谢谢你们!
I've just upgraded to Elastic Search 1.5.0 and so far I can't make inner_hits work with a nested filter, although it works fine with a nested query.
Let's say I want to retrieve the inner nested object actors within a movie object.
When I run the following nested query :
Syntax 1
GET my_index/movie/_search { "query": { "filtered": { "query": {"match_all": {}}, "filter": { "nested": { "path": "actors", "query": { "match": { "actors.id": 12345 } }, "inner_hits" : {} } } } } }
=> I get the inner_hits as documented here, which is just fine.
But when I try doing the equivalent query with a nested filter :
Syntax 2
GET my_index/movie/_search { "query": { "filtered": { "query": {"match_all": {}}, "filter": { "nested": { "path": "actors", "filter": { "term": { "actors.id": 12345 } }, "inner_hits" : {} } } } } }
=> I get the following parse error
QueryParsingException[[my_index] [nested] requires either 'query' or 'filter' field]
(and this last query works fine when I remove inner_hits - except of course that I don't get the inner hits ...)
Is there something wrong in the syntax I use or is the inner_hits not implemented yet with nested filter ?
Thanks in advance
Edit 3-30-2015
It works with the syntax provided below by @mdewit (thanks!)
Syntax 3
GET my_index/movie/_search { "query": { "nested": { "path": "actors", "query": { "filtered": { "filter": { "term": {"actors.id": 12345} } } }, "inner_hits" : {} } } }
even though this syntax does not match the Nested Filter doc
=> I still do not understand what is wrong with Syntax 2. It seems like an ES bug to me.
Edit 04-22-2015 : bug fixed in ES 1.5.1, see my comment below
解决方案Bug fixed in ElasticSearch 1.5.1 as stated here
So this syntax works (and works fine)
GET my_index/movie/_search { "query": { "filtered": { "query": {"match_all": {}}, "filter": { "nested": { "path": "actors", "filter": { "term": { "actors.id": 12345 } }, "inner_hits" : {} } } } } }
Thanks guys!
这篇关于内部命中不能使用嵌套过滤器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!