我的一个索引具有以下映射:
"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"
}
}
}
}
}
查询部分已更改,但是它仍然存在,我不确定是什么原因导致这种情况
答案 0 :(得分:1)
如果您未在映射中设置"dynamic": "strict"
,则可以通过索引新数据来扩展您的映射。您已将查询部分作为数据插入到索引中。重新索引数据时,所有数据都将传输到新索引,并且您仍会看到该发布和更改的映射。要避免这种情况,您需要在映射中设置"dynamic": "strict"
或尝试不为此类文档建立索引。
答案 1 :(得分:1)
这通常是将查询发布到与_search
端点不同的端点的结果。
例如,如果运行此命令,则将创建一个新文档并修改索引的映射
POST index/_doc
{
"query": {
"match_all": {}
}
}
查询必须始终发送到_search
端点:
POST index/_search
{
"query": {
"match_all": {}
}
}