大家好我正在尝试创建架构测试。
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
}
请帮我解决此错误
答案 0 :(得分:38)
你快到了,你只是缺少一些东西:
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": {
...
}
}
<强>更新强>
如果你的索引已经存在,你也可以修改你的映射:
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
答案 1 :(得分:13)
我希望以上答案适用于<7.0的弹性搜索,但是在7.0中,我们无法指定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
答案 2 :(得分:3)
从ES 7开始,已删除映射类型。您可以阅读更多详细信息here
如果您使用的是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
之后:
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
答案 3 :(得分:3)
我运行的是 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" }
}
}
}
}'
返回以下错误。
{
"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
}
为了缓解这种情况,请按如下方式修改查询中的 json。
curl -H 'Content-Type: application/json' -XPUT 127.0.0.1:9200/movies?pretty -d '
{
"mappings" : {
"properties" : {
"year" : { "type": "date" }
}
}
}'
注意:删除了“电影”:{} 层。现在它可以工作了。
答案 4 :(得分:0)
答案 5 :(得分:0)
WIT HCTE1 AS
(
SELECT
tran_ref,
MIN (CASE WHEN tran_id = 1 THEN [currency] END) AS cur1,
MIN (CASE WHEN tran_id <> 1 THEN [currency] END) AS cur23,
MIN (CASE WHEN tran_id = 1 THEN [Date] END) AS DATE_UPDATE
FROM
Table1_pivot1
GROUP BY
tran_ref
)
SELECT
A.tran_ref,
SUM(CASE WHEN A.tran_id = 1 THEN AMOUNT END) AS AMOUNT_01,
SUM(CASE WHEN A.tran_id = 2 THEN AMOUNT END) AS AMOUNT_02,
SUM(CASE WHEN A.tran_id = 3 THEN AMOUNT END) AS AMOUNT_03,
MIN(B.CUR1) AS CUR1,
MIN(B.CUR23) AS CUR23,
MIN(DATE_UPDATE) AS DATE_UPDATE,
COUNT(*) count_of_ref_rows
FROM
Table1_pivot1 A
INNER JOIN
CTE1 B ON (A.TRAN_REF = B.TRAN_REF)
GROUP BY
A.tran_ref;
这是我知道的类似命令:
PUT /testIndex
{
"mappings": {
"properties": { <--ADD THIS
"field1": {
"type": "integer"
},
"field2": {
"type": "integer"
},
"field3": {
"type": "string",
"index": "not_analyzed"
},
"field4": {
"type": "string",
"analyzer": "autocomplete",
"search_analyzer": "standard"
}
}
},
"settings": {
bla
bla
bla
}
}
上述curl命令的细分为:
curl -v -H "Content-Type: application/json" -H "Authorization: Basic cGC3COJ1c2Vy925hZGFJbXBvcnABCnRl" -X PUT -d '{"mappings":{"properties":{"city":{"type": "text"}}}}' https://35.80.2.21/manzanaIndex