我是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"
}
}
}
}
}
}
答案 0 :(得分:1)
Multi-fields have changed syntax在ES2和ES5之间。在ES 5中执行此操作的正确方法如下:
POST movies/movie/_mapping
{
"properties": {
"director": {
"type": "text"
"fields": {
"original": {
"type": "keyword"
}
}
}
}
}