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,

Sincerely,

A. Babilone

Hi,

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:
https://www.elastic.co/guide/en/elasticsearch/reference/1.7/query-dsl-indices-query.html

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: https://github.com/elastic/elasticsearch/issues/12016

Martijn

Hi,

Thanks for the quick response!

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

Sincerely,

Arnaud

Hi,

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

Thanks again,

Arnaud