And*_*iss 3 c# elasticsearch nest
我知道这之前已经被问过多次,但现有的问题或答案都没有帮助我。
查询 Elasticsearch 时出现以下错误:
[nested] 未能在路径 [departures] 下找到嵌套对象
我正在运行的查询如下:
{
"explain":true,
"from":0,
"query":{
"nested":{
"path":"departures",
"query":{
"term":{
"departures.yearMonth":{
"value":202007
}
}
}
}
},
"size":20
}
Run Code Online (Sandbox Code Playgroud)
我的映射如下:
{
"tours":{
"mappings":{
"properties":{
"departures":{
"type":"nested",
"properties":{
"guaranteed":{
"type":"boolean"
},
"spacesRemaining":{
"type":"long"
},
"startDate":{
"type":"date"
},
"yearMonth":{
"type":"long"
}
}
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
最后,从 Kibana 截取的屏幕截图显示我的索引中有一个有效条目。

任何想法为什么这个查询会像这样失败?
尝试ignore_unmapped在您的查询请求中将标志设置为 true
https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-nested-query.html
ignore_unmapped (可选,布尔值)指示是否忽略未映射的路径并且不返回任何文档而不是错误。默认为假。
如果为 false,并且路径是未映射的字段,则 Elasticsearch 将返回错误。
您可以使用此参数查询可能不包含字段路径的多个索引。