Elasticsearch错误“未能在路径下找到嵌套对象”

问题描述 投票:0回答:1

我知道这已经被问过多次了,但是现有的问题或答案都没有帮助我。

查询Elasticsearch时出现以下错误:

[嵌套]未能在路径[出发]下找到嵌套对象

我正在运行的查询如下:

{
    "explain":true,
    "from":0,
    "query":{
        "nested":{
            "path":"departures",
            "query":{
                "term":{
                    "departures.yearMonth":{
                        "value":202007
                    }
                }
            }
        }
    },
    "size":20
}

我的映射如下:

{
    "tours":{
        "mappings":{
            "properties":{
                "departures":{
                    "type":"nested",
                    "properties":{
                        "guaranteed":{
                            "type":"boolean"
                        },
                        "spacesRemaining":{
                            "type":"long"
                        },
                        "startDate":{
                            "type":"date"
                        },
                        "yearMonth":{
                            "type":"long"
                        }
                    }
                }
            }
        }
    }
}

最后,从Kibana截取的屏幕快照显示我的索引中有一个有效条目。enter image description here

关于此查询为什么会失败的任何想法?

c# elasticsearch nest
1个回答
0
投票

尝试在查询请求中将ignore_unmapped标志设置为true

https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-nested-query.html

ignore_unmapped(可选,布尔值)指示是否忽略未映射的路径并且不返回任何文档而不是返回错误。默认为false。

如果为false,如果路径是未映射的字段,则Elasticsearch返回错误。

您可以使用此参数查询可能不包含字段路径的多个索引。

最新问题
© www.soinside.com 2019 - 2024. All rights reserved.