Internal hits not working with nested filter?

I 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.

Suppose I want to extract an internal subject inside a movie object.

When I run the following subquery :

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 inner_hits as documented here , which is very good.

But when I try to execute an 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 parsing error

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

(and this last request works fine when I delete inner_hits - except that I don't get inner images ...)

Is there something wrong with the syntax I'm using, or is inner_face not yet implemented with a filter attached?

Thanks in advance

Edit 3-30-2015

It works with the syntax below @mdewit (thanks!)

Syntax 3

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

although this syntax does not match the nested doc filter

=> I still do not understand what is wrong with syntax 2. It seems to me that the ES error is for me.

Edit 04-22-2015: bug fixed in ES 1.5.1, see my comment below

+7
elasticsearch
source share
2 answers

Bug fixed in ElasticSearch 1.5.1 as indicated here

So this syntax works (and works great)

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

Thanks guys!

+2
source share

The following seems to work:

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

All Articles