大家好我正在尝试创建架构测试。
PUT /test
{
"mappings": {
"field1":{
"type":"integer"
},
"field2":{
"type":"integer"
},
"field3":{
"type":"string",
"index":"not_analyzed"
},
"field4,":{
"type":"string",
"analyzer":"autocomplete",
"search_analyzer":"standard"
}
},
"settings": {
bla
bla
bla
}
我收到以下错误
{
"error": {
"root_cause": [
{
"type": "mapper_parsing_exception",
"reason": "Root mapping definition has unsupported parameters: [index : not_analyzed] [type : string]"
}
],
"type": "mapper_parsing_exception",
"reason": "Failed to parse mapping [featured]: Root mapping definition has unsupported parameters: [index : not_analyzed] [type : string]",
"caused_by": {
"type": "mapper_parsing_exception",
"reason": "Root mapping definition has unsupported parameters: [index : not_analyzed] [type : string]"
}
},
"status": 400
}
请帮我解决这个错误
你几乎在这里,你只是缺少一些东西:
PUT /test
{
"mappings": {
"type_name": { <--- add the type name
"properties": { <--- enclose all field definitions in "properties"
"field1": {
"type": "integer"
},
"field2": {
"type": "integer"
},
"field3": {
"type": "string",
"index": "not_analyzed"
},
"field4,": {
"type": "string",
"analyzer": "autocomplete",
"search_analyzer": "standard"
}
}
}
},
"settings": {
...
}
}
UPDATE
如果索引已存在,您还可以修改映射,如下所示:
PUT test/_mapping/type_name
{
"properties": { <--- enclose all field definitions in "properties"
"field1": {
"type": "integer"
},
"field2": {
"type": "integer"
},
"field3": {
"type": "string",
"index": "not_analyzed"
},
"field4,": {
"type": "string",
"analyzer": "autocomplete",
"search_analyzer": "standard"
}
}
}
更新:
从ES 7开始,映射类型已被删除。你可以阅读更多细节here
我希望上面的答案适用于弹性搜索<7.0但在7.0中我们不能指定文档类型,它不再受支持。在这种情况下,如果我们指定doc类型,我们会得到类似的错误。
我正在使用Elastic search 7.0和Nest C #lastest version(6.6)。 ES 7.0有一些重大变化导致了这个问题。这是因为我们无法指定doc类型,并且在NEST的6.6版本中它们使用doctype。因此,为了解决直到NEST 7.0发布,我们需要下载他们的测试包
请通过此链接进行修复
https://xyzcoder.github.io/elasticsearch/nest/2019/04/12/es-70-and-nest-mapping-error.html