gpt4 book ai didi

elasticsearch - Elasticsearch 创建新的映射,而不是加入已经定义的映射?

转载 作者:行者123 更新时间:2023-12-03 01:47:06 25 4
gpt4 key购买 nike

我用下面给出的映射创建了一个索引。并且索引为空

{
"content": {
"mappings": {
"university": {
"properties": {
"state": {
"type": "nested",
"properties": {
"pincode": {
"type": "long"
},
"region": {
"type": "string",
"index": "not_analyzed"
}
}
}
}
}
}
}
}

当我插入这样的文档时:
PUT content/university/1
{
"university": [
{
"state": {
"region": "usa",
"pincode": 5693
}
}
]
}

它正在创建一个新的映射,而不是加入先前定义的映射。
{
"content": {
"mappings": {
"university": {
"properties": {
"state": {
"type": "nested",
"properties": {
"pincode": {
"type": "long"
},
"region": {
"type": "string",
"index": "not_analyzed"
}
}
},
"university": {
"properties": {
"state": {
"properties": {
"pincode": {
"type": "long"
},
"region": {
"type": "string"
}
}
}
}
}
}
}
}
}
}

我如何在Elasticsearch中避免这种情况?

我是否必须为此使用内联脚本?

最佳答案

如果您想索引以下文档,则:

PUT content/university/1
{
"university": [
{
"state": {
"region": "usa",
"pincode": 5693
}
}
]
}

映射应如下所示定义:
PUT content
{
"mappings": {
"university": {
"properties": {
"university": {
"type": "nested",
"properties": {
"state": {
"type": "nested",
"properties": {
"pincode": {
"type": "long"
},
"region": {
"type": "string",
"index": "not_analyzed"
}
}
}
}
}
}
}
}
}

关于elasticsearch - Elasticsearch 创建新的映射,而不是加入已经定义的映射?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43099854/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com