Search query exception "org.elasticsearch.index.query.QueryShardException: failed to create query"

Hello,
I am using elasticsearch version 7.3.1, on my local setup search query execution works fine.
But the same query using docker image for es version 7.3.1 on kubernetes recently I am facing following exception:
"message": "All shards failed for phase: [query]" ,
stacktrace": ["org.elasticsearch.index.query.QueryShardException: failed to create query: {",
"bool" : {",
"must" : [",
{",
"term" : {",
"username" : {",
"value" : "12345",",
"boost" : 1.0",
}",
}",
},",
{",
"nested" : {",
"query" : {",
"exists" : {",
"field" : "email_addresses.value",",
"boost" : 1.0",
}",
},",
"path" : "email_addresses",",
"ignore_unmapped" : false,",
"score_mode" : "avg",",
"boost" : 1.0",
}",
}",
],",
"should" : [",
{",
"nested" : {",
"query" : {",
"multi_match" : {",
"query" : "abc",",
"fields" : [",
"email_addresses.value^3.0",",
"family_name^1.0",",
"given_name^2.0"",
],",
"type" : "bool_prefix",",
"operator" : "OR",",
"slop" : 0,",
"prefix_length" : 0,",
"max_expansions" : 50,",
"zero_terms_query" : "NONE",",
"auto_generate_synonyms_phrase_query" : true,",
"fuzzy_transpositions" : true,",
"boost" : 1.0",
}",
},",
"path" : "email_addresses",",
"ignore_unmapped" : false,",
"score_mode" : "avg",",
"boost" : 1.0",
}", },",
{",
"multi_match" : {",
"query" : "abc",",
"fields" : [",
"email_addresses.value^3.0",",
"family_name^1.0",",
"given_name^2.0"",
],",
"type" : "bool_prefix",",
"operator" : "OR",",
"slop" : 0,",
"prefix_length" : 0,",
"max_expansions" : 50,",
"zero_terms_query" : "NONE",",
"auto_generate_synonyms_phrase_query" : true,",
"fuzzy_transpositions" : true,",
"boost" : 1.0",
}",
}",
],",
"adjust_pure_negative" : true,",
"minimum_should_match" : "1",",
"boost" : 1.0",
}",
}",
"Caused by: java.lang.IllegalStateException: [nested] nested object under path [email_addresses] is not of nested type",

Please help

Welcome.

Here email_addresses is not of nested type in your mapping. So you can't use nested queries.

Please format your code, logs or configuration files using </> icon as explained in this guide and not the citation button. It will make your post more readable.

Or use markdown style like:

```
CODE
```

This is the icon to use if you are not using markdown format:

There's a live preview panel for exactly this reasons.

Lots of people read these forums, and many of them will simply skip over a post that is difficult to read, because it's just too large an investment of their time to try and follow a wall of badly formatted text.
If your goal is to get an answer to your questions, it's in your interest to make it as easy to read and understand as possible.

Thanks for your reply, could you please elaborate of what do you mean by email_addresses is not of nested type?

That's a guess. Check the mapping.

But same query with same elasticsearch version works on local machine setup. Is there anything I am missing

What is the mapping in both cases?

Thank you so much for your pointer there was different mappings due to which search was failing it is working for me now.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.