gpt4 book ai didi

Elasticsearch 映射不工作

转载 作者:行者123 更新时间:2023-11-29 02:47:31 25 4
gpt4 key购买 nike

尝试使用以下命令在 Elasticsearch 2 下创建映射,但失败了:

POST /my_blog    
{
"settings": {
"index" : {
"number_of_shards" : 10
}
},
"mappings": {
"post" : {
"_routing" : {
"required": false,
"path" : "post_date"
},
"properties": {
"user_id" :{
"type": "integer"
},
"post_text" : {
"type": "string"
},
"post_date": {
"type" : "date",
"format" : "YYYY-MM-DD"
}
}
}
}
}

响应:

{
"error": {
"root_cause": [
{
"type": "mapper_parsing_exception",
"reason": "Mapping definition for [_routing] has unsupported parameters: [path : post_date]"
}
],
"type": "mapper_parsing_exception",
"reason": "mapping [post]",
"caused_by": {
"type": "mapper_parsing_exception",
"reason": "Mapping definition for [_routing] has unsupported parameters: [path : post_date]"
}
},
"status": 400
}

无论我为路径选择什么字段,整数/字符串或日期,它总是给出相同的错误回复(见上文)。有什么想法吗?

最佳答案

看看 type meta-field changes in 2.0 .您正在尝试做的事情无法再完成。

您必须像这样创建索引:

POST /my_blog    
{
"settings": {
"index" : {
"number_of_shards" : 10
}
},
"mappings": {
"post" : {
"_routing" : {
"required": false
},
"properties": {
"user_id" :{
"type": "integer"
},
"post_text" : {
"type": "string"
},
"post_date": {
"type" : "date",
"format" : "YYYY-MM-DD"
}
}
}
}
}

然后在每个索引文档的查询字符串中指定路由,如:

PUT /my_blog/post/1?routing=2015-11-19
{
"user_id": 1,
"post_text": "Lorem ipsum",
"post_date": "2015-11-19"
}

关于Elasticsearch 映射不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33810142/

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