内部命中不适用于嵌套过滤器? [英] Inner hits not working with nested filter?
问题描述
我刚刚升级到 Elastic Search 1.5.0,到目前为止我无法制作 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.
假设我想检索 movie 对象中的内部嵌套对象 actors.
Let's say I want to retrieve the inner nested object actors within a movie object.
当我运行以下嵌套查询时:
语法 1
GET my_index/movie/_search
{
"query": {
"filtered": {
"query": {"match_all": {}},
"filter": {
"nested": {
"path": "actors",
"query": {
"match": {
"actors.id": 12345
}
},
"inner_hits" : {}
}
}
}
}
}
=> 我得到了记录在案的 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 :
语法 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] 需要 'query' 或'过滤器'字段]
QueryParsingException[[my_index] [nested] requires either 'query' or 'filter' field]
(当我删除 inner_hits 时,这最后一个查询工作正常 - 当然,除了我没有得到内部命中...)
(and this last query works fine when I remove inner_hits - except of course that I don't get the inner hits ...)
我使用的语法是否有问题,或者嵌套过滤器尚未实现inner_hits?
Is there something wrong in the syntax I use or is the inner_hits not implemented yet with nested filter ?
提前致谢
编辑 3-30-2015
它使用 @mdewit(谢谢!)
语法 3
GET my_index/movie/_search
{
"query": {
"nested": {
"path": "actors",
"query": {
"filtered": {
"filter": {
"term": {"actors.id": 12345}
}
}
},
"inner_hits" : {}
}
}
}
即使此语法与 嵌套过滤器文档
=> 我仍然不明白语法 2 有什么问题.对我来说这似乎是一个 ES 错误.
=> 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
Edit 04-22-2015 : bug fixed in ES 1.5.1, see my comment below
推荐答案
在 ElasticSearch 1.5.1 中修复了错误,如所述 这里
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" : {}
}
}
}
}
}
谢谢各位!
这篇关于内部命中不适用于嵌套过滤器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!