Reputation: 3914
I know this has been asked multiple times before but none of the existing questions or answers have helped me.
I am getting the following error when querying Elasticsearch:
[nested] failed to find nested object under path [departures]
The query I am running is below:
{
"explain":true,
"from":0,
"query":{
"nested":{
"path":"departures",
"query":{
"term":{
"departures.yearMonth":{
"value":202007
}
}
}
}
},
"size":20
}
And my mapping is as follows:
{
"tours":{
"mappings":{
"properties":{
"departures":{
"type":"nested",
"properties":{
"guaranteed":{
"type":"boolean"
},
"spacesRemaining":{
"type":"long"
},
"startDate":{
"type":"date"
},
"yearMonth":{
"type":"long"
}
}
}
}
}
}
}
And finally, a screenshot taken from Kibana showing that there is a valid entry in my index.
Any ideas why this query would be failing like this?
Upvotes: 6
Views: 14391
Reputation: 17745
Try setting the ignore_unmapped
flag to true on your query request
https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-nested-query.html
ignore_unmapped (Optional, boolean) Indicates whether to ignore an unmapped path and not return any documents instead of an error. Defaults to false.
If false, Elasticsearch returns an error if the path is an unmapped field.
You can use this parameter to query multiple indices that may not contain the field path.
Upvotes: 8