gpt4 book ai didi

elasticsearch - 为什么 Elasticsearch "not_analyzed"字段被拆分成术语?

转载 作者:行者123 更新时间:2023-11-29 02:43:42 24 4
gpt4 key购买 nike

我的映射定义中有以下字段:

...
"my_field": {
"type": "string",
"index":"not_analyzed"
}
...

当我索引一个值为 my_field = 'test-some-another' 的文档时,该值被分成 3 个术语:testsome另一个

我做错了什么?

我创建了以下索引:

curl -XPUT localhost:9200/my_index -d '{
"index": {
"settings": {
"number_of_shards": 5,
"number_of_replicas": 2
},
"mappings": {
"my_type": {
"_all": {
"enabled": false
},
"_source": {
"compressed": true
},
"properties": {
"my_field": {
"type": "string",
"index": "not_analyzed"
}
}
}
}
}
}'

然后我索引以下文档:

curl -XPOST localhost:9200/my_index/my_type -d '{
"my_field": "test-some-another"
}'

然后我使用插件 https://github.com/jprante/elasticsearch-index-termlist使用以下 API:
curl -XGET localhost:9200/my_index/_termlist
这给了我以下回应:



{"ok":true,"_shards":{"total":5,"successful":5,"failed":0},"terms": ["test","some", “其他”]}

最佳答案

通过运行验证映射是否真的被设置:

curl localhost:9200/my_index/_mapping?pretty=true

创建索引的命令似乎不正确。它不应包含 "index": { 作为根元素。试试这个:

curl -XPUT localhost:9200/my_index -d '{
"settings": {
"number_of_shards": 5,
"number_of_replicas": 2
},
"mappings": {
"my_type": {
"_all": {
"enabled": false
},
"_source": {
"compressed": true
},
"properties": {
"my_field": {
"type": "string",
"index": "not_analyzed"
}
}
}
}
}'

关于elasticsearch - 为什么 Elasticsearch "not_analyzed"字段被拆分成术语?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10583013/

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