gpt4 book ai didi

types - Elasticsearch,类型属性与类型映射有什么区别?

转载 作者:行者123 更新时间:2023-12-03 00:23:29 24 4
gpt4 key购买 nike

如果有人可以帮助理解以下两种形式的类型之间的真正区别,我将不胜感激:

使用“映射”

PUT / mybestfares_test1

{
"mappings": {
"bestfares_data": {
"dynamic" : false,
"properties": {
"airline": {
"type": "string",
"index": "not_analyzed",
"null_value": "N/A"
},
"destinationAirport": {
"type": "string",
"index": "not_analyzed",
"null_value": "N/A"
},
"originAirport": {
"type": "string",
"index": "not_analyzed",
"null_value": "N/A"
},
"sellPrice": {
"type": "double",
"null_value": 0
}
}
}
}
}

不使用“映射”

PUT / mybestfares_test2 /
{
"bestfares_data": {
"dynamic" : false,
"properties": {
"airline": {
"type": "string",
"index": "not_analyzed",
"null_value": "N/A"
},
"destinationAirport": {
"type": "string",
"index": "not_analyzed",
"null_value": "N/A"
},
"originAirport": {
"type": "string",
"index": "not_analyzed",
"null_value": "N/A"
},
"sellPrice": {
"type": "double",
"null_value": 0
}
}
}
}

如果我获取了这两个索引的索引信息,则很明显,“mybestfares_test2”没有任何“映射”定义,尽管该类型中的每个字段都有特定的设置:

GET / mybestfares_test2 =>
{
"mybestfares_test2": {
"mappings": {},
"settings": {
"index": {
"creation_date": "1423741207570",
"uuid": "ognGDfnTS7i9AVE1L66UgA",
"number_of_replicas": "1",
"number_of_shards": "5",
"version": {
"created": "1040299"
},
"bestfares_data": {
"dynamic" : false,
"properties": {
"destinationAirport": {
"type": "string",
"null_value": "N/A",
"index": "not_analyzed"
},
"sellPrice": {
"type": "double",
"null_value": "0"
},
"originAirport": {
"type": "string",
"null_value": "N/A",
"index": "not_analyzed"
},
"airline": {
"type": "string",
"null_value": "N/A",
"index": "not_analyzed"
}
}
}
}
}
}
}

当然,使用映射创建的索引对映射{...}部分中的字段具有相同的设置
GET / mybestfares_test1
{
"mybestfares_test1": {
"mappings": {
"bestfares_data": {
"dynamic" : false,
"properties": {
"airline": {
"type": "string",
"index": "not_analyzed",
"null_value": "N/A"
},
"destinationAirport": {
"type": "string",
"index": "not_analyzed",
"null_value": "N/A"
},
"originAirport": {
"type": "string",
"index": "not_analyzed",
"null_value": "N/A"
},
"sellPrice": {
"type": "double",
"null_value": 0
}
}
}
},
"settings": {
"index": {
"creation_date": "1423741360578",
"uuid": "rZ8wc2-2TGKVo8ZVd8YIKg",
"number_of_replicas": "1",
"number_of_shards": "5",
"version": {
"created": "1040299"
}
}
}
}
}

我想了解这两个索引之间有什么不同的事物(如果有的话)?

最佳答案

如果仔细查看响应,则创建的没有映射的第二个索引实际上会获得许多其他设置。因此,在这种情况下,您将不提供映射。因此,第一个是唯一正确的。

关于types - Elasticsearch,类型属性与类型映射有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28477062/

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