支持多种语言的Elasticsearch
我使用的是elasticsearch 5.1.1。 我有一个要求,在这里我想用多种语言索引数据 我使用了以下映射: 放 当我尝试插入一些数据时,如下所示: 职位 我遇到以下错误:支持多种语言的Elasticsearch,
Warning: implode(): Invalid arguments passed in /data/phpspider/zhask/webroot/tpl/detail.html on line 45
,,我使用的是elasticsearch 5.1.1。 我有一个要求,在这里我想用多种语言索引数据 我使用了以下映射: 放 当我尝试插入一些数据时,如下所示: 职位 我遇到以下错误: { "error": { "root_cause": [ { "type": "remote_transport_exception", "reason": "[IQ7CUTp][127.0.0.1:9300][indices:data/write/index[p
{
"error": {
"root_cause": [
{
"type": "remote_transport_exception",
"reason": "[IQ7CUTp][127.0.0.1:9300][indices:data/write/index[p]]"
}
],
"type": "illegal_argument_exception",
"reason": "[title] is defined as an object in mapping [movie] but this name is already used for a field in other types"
},
"status": 400
}
有人能告诉我这里出了什么问题吗?如我所见,您已经将
标题定义为类型和属性。
这个错误似乎说明了这个问题
从你的电话留言中,我看到类型是电影。
你真的想把标题作为一种类型吗?
您应该在电影类型中定义标题的映射。问题是标题
字段被声明为字符串
,您正试图访问标题.en
子字段,就像标题
是和对象
字段一样。您需要像这样更改映射,然后它就会工作:
{
"mappings": {
"title": {
"properties": {
"title": {
"type": "object", <--- change this
"properties": { <--- and this
"de": {
"type": "string",
"analyzer": "german"
},
"en": {
"type": "string",
"analyzer": "english"
},
"fr": {
"type": "string",
"analyzer": "french"
},
"es": {
"type": "string",
"analyzer": "spanish"
}
}
}
}
}
}
}
{
“映射”:{
“标题”:{
“财产”:{
“标题”:{
“类型”:“对象”,谢谢Val和@christinabo,你的两个解决方案都有效。基本上我想用“电影”作为类型。现在我可以发布数据。现在我想测试我的分析器是否真的适用于不同的语言,我该如何做。现在它接受我在搜索中发布和返回的内容。在字段上设置english
分析器不会阻止您将西班牙语内容索引到其中,因此ES将接受您输入的任何字符串在所有语言特定的字段中使用st。最好的测试方法是点击并查看如何分析文本。使用西班牙语分析器分析summer
没有问题。ES不会翻译您的内容。好的,谢谢,看起来我需要更深入地阅读有关分析器的内容:)但您能简要介绍一下优点吗使用“西班牙语”分析器或特定语言分析器的时代,因为我们可以使用“英语”分析器实现相同的功能?如果问题非常基本,则表示歉意。每种分析器针对每种语言应用不同的规则(词干、停止词等)。您一定要仔细阅读。
{
"error": {
"root_cause": [
{
"type": "remote_transport_exception",
"reason": "[IQ7CUTp][127.0.0.1:9300][indices:data/write/index[p]]"
}
],
"type": "illegal_argument_exception",
"reason": "[title] is defined as an object in mapping [movie] but this name is already used for a field in other types"
},
"status": 400
}
{
"mappings": {
"title": {
"properties": {
"title": {
"type": "object", <--- change this
"properties": { <--- and this
"de": {
"type": "string",
"analyzer": "german"
},
"en": {
"type": "string",
"analyzer": "english"
},
"fr": {
"type": "string",
"analyzer": "french"
},
"es": {
"type": "string",
"analyzer": "spanish"
}
}
}
}
}
}
}