内部命中不适用于嵌套过滤器?

Inner hits not working with nested filter?

我刚刚升级到 Elastic Search 1.5.0,到目前为止我还不能 inner_hits 使用嵌套过滤器,尽管它可以很好地使用嵌套查询。

假设我想检索 movie 对象中的内部嵌套对象 actors

当我运行以下嵌套查询时:

语法 1

GET my_index/movie/_search
{
  "query": {
    "filtered": {
      "query": {"match_all": {}},
      "filter": {
        "nested": {
          "path": "actors",
          "query": {
            "match": {
              "actors.id": 12345
            }
          }, 
          "inner_hits" : {}
        }
      }
    }
  }
}

=> 我得到 inner_hits 记录 here,这很好。

但是当我尝试使用 嵌套过滤器 进行等效查询时:

语法 2

GET my_index/movie/_search
{
  "query": {
    "filtered": {
      "query": {"match_all": {}},
      "filter": {
        "nested": {
          "path": "actors",
          "filter": {
            "term": {
              "actors.id": 12345
            }
          }, 
          "inner_hits" : {}
        }
      }
    }
  }
}

=> 我收到以下解析错误

QueryParsingException[[my_index] [nested] requires either 'query' or 'filter' field]

(最后一个查询在我删除 inner_hits 时工作正常 - 当然除了我没有得到内部命中...)

我使用的语法有问题还是 inner_hits 尚未使用嵌套过滤器实现?

提前致谢

编辑 2015 年 3 月 30 日

它使用下面由 @mdewit 提供的语法(谢谢!)

语法 3

GET my_index/movie/_search
{
    "query": {
        "nested": {
            "path": "actors",
            "query": {
                "filtered": {
                    "filter": {
                        "term": {"actors.id": 12345}
                    }
                }
            },
            "inner_hits" : {}
        }
    }
}

即使此语法与 Nested Filter doc

不匹配

=> 我仍然不明白 Syntax 2 有什么问题。对我来说这似乎是一个 ES 错误。

编辑 04-22-2015:修复了 ES 1.5.1 中的错误,请参阅下面的评论

以下似乎有效:

GET my_index/movie/_search
{
    "query": {
        "nested": {
            "path": "actors",
            "query": {
                "filtered": {
                    "filter": {
                        "term": {"actors.id": 12345}
                    }
                }
            },
            "inner_hits" : {}
        }
    }
}'

错误已在 ElasticSearch 1.5.1 中修复,如所述here

所以这个语法有效(并且工作正常)

GET my_index/movie/_search
{
  "query": {
    "filtered": {
      "query": {"match_all": {}},
      "filter": {
        "nested": {
          "path": "actors",
          "filter": {
            "term": {
              "actors.id": 12345
            }
          }, 
          "inner_hits" : {}
        }
      }
    }
  }
}

谢谢大家!