gpt4 book ai didi

elasticsearch - Elasticsearch从2x映射到5x

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

我是Elastic的新手,我很难将简单的映射从2x版本转换为5x版本

这里是映射

POST movies/movie/_mapping
{
"properties": {
"director": {
"type": "multi_field",
"fields": {
"director": {
"type": "string"
},
"original": {
"type": "string",
"index": "not_analyzed"
}
}
}
}
}

这是我在5x版本中出现的错误
{
"error": {
"root_cause": [
{
"type": "mapper_parsing_exception",
"reason": "No handler for type [multi_field] declared on field [director]"
}
],
"type": "mapper_parsing_exception",
"reason": "No handler for type [multi_field] declared on field [director]"
},
"status": 400
}

我尝试这样做
PUT movies/movie/_mapping
{
"_all": {
"enabled": true
},
"properties": {
"director": {
"type": "text"
}
}
}

我收到了
{
"acknowledged": true
}

但是它没有按预期工作。

目标是:场长包含“弗朗西斯·福特·科波拉”

感谢@Val,由于映射已更改,现在可以重新索引了。
但是我想做的不能正常工作。

在这里我想做什么
GET movies/_search
{
"query": {
"bool": {
"filter": {
"term": {
"director": "francis ford coppola"
}
}
}
}
}

我没有这个热门。

我有两个热门:
GET movies/_search
{
"query": {
"bool": {
"filter": {
"terms": {
"director": ["francis", "ford", "coppola"]
}
}
}
}
}

这是我当前的映射
{
"movies": {
"mappings": {
"movie": {
"properties": {
"director": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"genres": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"title": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"year": {
"type": "long"
}
}
}
}
}
}

最佳答案

ES2和ES5之间的Multi-fields have changed syntax。在ES 5中执行此操作的正确方法如下:

POST movies/movie/_mapping
{
"properties": {
"director": {
"type": "text"
"fields": {
"original": {
"type": "keyword"
}
}
}
}
}

关于elasticsearch - Elasticsearch从2x映射到5x,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51630438/

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