Search on a nested field on multi-indexes, multi-document types throw QueryParsingException

Hi everyone,

I'm facing a strange issue when performing a search on an nested field on multiple indexes, multiple document types.

First of all, we are working on elasticsearch 1.7.3.

My search is on two indexes, which each have one distinct document type inside.
My nested field is declared only in one of the two document type mapping.

The request returns a QueryParsingException telling "[indexname] [nested] failed to find nested object under path [xyz]]"", only for the index which contains the document type without the nested field.

If I execute my search request only on the index which contains the document type with the nested field, everything works as expected. So this does not seems like a query syntax error.

If I execute a search on the same two indexes, on a field defined only in one of the two document type, but which is not of nested type, everything works as expected.

Thanks in advance for any help,


A. Babilone


Compared to the other queries the nested query is strict when it comes to the existence of a nested field in the mapping and like you're saying it we fail with an error if no nested field can be found.

There is no good work around for this, but what you could try out is to wrap the nested query in an indices query:

wrap your nested query inside this indices query and only execute this query on indices you know have the nested field you're referring to.

In the future we will handle strictness for nested query and other queries better:



Thanks for the quick response!

I'll try to wrap my query in an indice query and see the outcome.




After some tests everything works now as expected when wrapping query part in indice query when needed.

Thanks again,