gpt4 book ai didi

rest - 用于自定义映射的elasticsearch动态模板不起作用

转载 作者:行者123 更新时间:2023-12-03 00:07:44 25 4
gpt4 key购买 nike

我正在尝试添加动态模板。我已经搞定了

curl -XPUT 'localhost:9200/my_index_items?pretty' -H 'Content-Type: application/json' -d'
{
"mappings": {
"item": {
"dynamic_templates": [
{
"sales_price_in_cent_as_long": {
"match": "sales_price_in_cent",
"mapping": {
"type": "long"
}
},
"sales_price_formatted_as_double": {
"match": "sales_price_formatted",
"mapping": {
"type": "double"
}
},
...
}
]
}
}
}
'

因此,在“my_index_items”中,我获得了“item”类型,当我现在为一个项目建立索引(item具有字段“sales_price_formatted”,其值类似于“12,34”)并使用GET'localhost:9200 / my_index_items / item查找/ _mapping”,则显示类型为“文本”而不​​是“ double ”的“sales_price_formatted”。

难道我做错了什么?我以为,如果某项的字段在我的动态模板的“match”属性中定义,那么它不会使用自己的默认机制,而是在此处定义的机制?

最佳答案

您的命令中缺少一些花括号。应该是这样的:

{
"mappings": {
"item": {
"dynamic_templates": [
{
"sales_price_in_cent_as_long": {
"match": "sales_price_in_cent",
"mapping": {
"type": "long"
}
}
},
{
"sales_price_formatted_as_double": {
"match": "sales_price_formatted",
"mapping": {
"type": "double"
}
}
}
]
}
}
}

关于rest - 用于自定义映射的elasticsearch动态模板不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43663154/

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