gpt4 book ai didi

elasticsearch - ElasticSearch:如何为数组字段添加映射?

转载 作者:行者123 更新时间:2023-12-03 01:57:00 31 4
gpt4 key购买 nike

elasticsearch中的样本文档:

{
"name": "Tom",
"hobbies": [
{
"hobby": "go for a walk"
},
{
"hobby": "board games"
}
]
}

这是为“名称”添加的映射:
{
"person": {
"_all": {
"analyzer": "ik_max_word",
"search_analyzer": "ik_max_word",
"term_vector": "no",
"store": "false"
},
"properties": {
"name": {
"type": "string",
"store": "no",
"term_vector": "with_positions_offsets",
"analyzer": "ik_max_word",
"search_analyzer": "ik_max_word",
"include_in_all": "true",
"boost": 8
}
}
}
}

问题:如何为hobbies.hobby添加映射?我想为分析器指定此字段-> ik_max_word

最佳答案

好的,根据Object datatype description,应该这样进行:

{
"person": {
"_all": {
"analyzer": "ik_max_word",
"search_analyzer": "ik_max_word",
"term_vector": "no",
"store": "false"
},
"properties": {
"name": {
"type": "string",
"store": "no",
"term_vector": "with_positions_offsets",
"analyzer": "ik_max_word",
"search_analyzer": "ik_max_word",
"include_in_all": "true",
"boost": 8
},
"hobbies": {
"properties": {
"hobby": {
"type": "string",
"store": "no",
"term_vector": "with_positions_offsets",
"analyzer": "ik_max_word",
"search_analyzer": "ik_max_word",
"include_in_all": "true",
"boost": 8
}
}
}
}
}
}

关于elasticsearch - ElasticSearch:如何为数组字段添加映射?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35857315/

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