ES 索引映射有 "query" 参数

ES index mapping has "query" parameter

我的一个索引有这个映射:

"mappings": {
            "properties": {
                "count": {
                    "type": "integer"
                },
                "currency": {
                    "type": "text",
                    "fields": {
                        "keyword": {
                            "type": "keyword",
                            "ignore_above": 16
                        }
                    }
                },
                "query": {
                    "properties": {
                        "match_all": {
                            "type": "object"
                        },
                        "range": {
                            "properties": {
                                "hour": {
                                    "properties": {
                                        "gte": {
                                            "type": "date"
                                        },
                                        "lt": {
                                            "type": "date"
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }

我不明白为什么会这样,所以我创建了一个新索引并确保它没有这个 query 绒毛。确保新索引的映射没有问题后,我开始重新索引过程,但过了一段时间,我再次注意到这一点:

"mappings": {
            "properties": {
                "count": {
                    "type": "integer"
                },
                "currency": {
                    "type": "keyword",
                    "index_options": "freqs"
                },
                "query": {
                    "properties": {
                        "match_all": {
                            "type": "object"
                        }
                    }
                }
            }
        }

query 部分已更改,但它仍然存在,我不确定是什么导致它变成这样

当您未在映射中设置 "dynamic": "strict" 时,您的映射将被允许通过索引新数据进行传播。您已将查询部分作为数据插入到索引中。当您重新索引数据时,所有数据都将转移到新索引,您仍然会看到 post 和更改映射。要没有这个,您需要在映射中设置 "dynamic": "strict" 或尽量不索引此类文档。

这通常是将查询发布到不同于 _search 端点的端点的结果。

例如,如果您 运行 这个,您将创建一个新文档 并修改索引的映射

POST index/_doc
{
  "query": {
    "match_all": {}
  }
}

查询必须始终发送到 _search 端点:

POST index/_search
{
  "query": {
    "match_all": {}
  }
}