Ram*_*esh 46 mapping elasticsearch
大家好我正在尝试创建架构测试.
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
}
}
Run Code Online (Sandbox Code Playgroud)
我收到以下错误
{
"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
}
Run Code Online (Sandbox Code Playgroud)
请帮我解决这个错误
Val*_*Val 70
你几乎在这里,你只是缺少一些东西:
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": {
...
}
}
Run Code Online (Sandbox Code Playgroud)
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"
}
}
}
Run Code Online (Sandbox Code Playgroud)
Pav*_*ulu 16
我希望上述答案适用于<7.0的弹性搜索,但是在7.0中,我们无法指定doc type,因此不再支持。在这种情况下,如果我们指定doc type,则会得到类似的错误。
我正在使用Elastic search 7.0和Nest C#最新版本(6.6)。ES 7.0的某些重大更改导致了此问题。这是因为我们无法指定文件类型,而在NEST的6.6版中,他们使用的是文件类型。因此,为了解决NEST 7.0发行之前的问题,我们需要下载其Beta版软件包
请通过此链接进行修复
https://xyzcoder.github.io/elasticsearch/nest/2019/04/12/es-70-and-nest-mapping-error.html
编辑:现在发布NEST 7.0。NEST 7.0可与Elastic 7.0一起使用。有关详细信息,请参见此处的发行说明。
Viv*_*Dev 10
我正在运行 Elastic Search 版本 7.12
当我运行以下命令时
curl -H 'Content-Type: application/json' -XPUT 127.0.0.1:9200/movies?pretty -d '
{
"mappings" : {
"movie": {
"properties" : {
"year" : { "type": "date" }
}
}
}
}'
Run Code Online (Sandbox Code Playgroud)
返回以下错误。
{
"error" : {
"root_cause" : [
{
"type" : "mapper_parsing_exception",
"reason" : "Root mapping definition has unsupported parameters: [movie : {properties={year={type=date}}}]"
}
],
"type" : "mapper_parsing_exception",
"reason" : "Failed to parse mapping [_doc]: Root mapping definition has unsupported parameters: [movie : {properties={year={type=date}}}]",
"caused_by" : {
"type" : "mapper_parsing_exception",
"reason" : "Root mapping definition has unsupported parameters: [movie : {properties={year={type=date}}}]"
}
},
"status" : 400
}
Run Code Online (Sandbox Code Playgroud)
为了缓解这种情况,请按如下方式修改查询中的 json。
curl -H 'Content-Type: application/json' -XPUT 127.0.0.1:9200/movies?pretty -d '
{
"mappings" : {
"properties" : {
"year" : { "type": "date" }
}
}
}'
Run Code Online (Sandbox Code Playgroud)
注意:删除了“movie”:{} 层。现在可以了。
从 ES 7 开始,映射类型已被删除。您可以在此处阅读更多详细信息
如果您使用 Ruby On Rails,这意味着您可能需要document_type从模型或关注点中删除。
作为映射类型的替代方案,一种解决方案是对每个文档类型使用索引。
前:
module Searchable
extend ActiveSupport::Concern
included do
include Elasticsearch::Model
include Elasticsearch::Model::Callbacks
index_name [Rails.env, Rails.application.class.module_parent_name.underscore].join('_')
document_type self.name.downcase
end
end
Run Code Online (Sandbox Code Playgroud)
后:
module Searchable
extend ActiveSupport::Concern
included do
include Elasticsearch::Model
include Elasticsearch::Model::Callbacks
index_name [Rails.env, Rails.application.class.module_parent_name.underscore, self.name.downcase].join('_')
end
end
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
59836 次 |
| 最近记录: |