为弹性搜索索引创建映射时出现 MapperParsingException
MapperParsingException when creating mapping for elasticsearch index
我正在尝试使用 sense 为具有三个属性的索引创建映射。当我尝试创建它时,我得到以下响应
{
"error": "MapperParsingException[Root type mapping not empty after parsing! Remaining fields: [mappings : {gram={properties={gram={type=string, fields={gram_bm25={type=string, similarity=BM25}, gram_lmd={type=string}}}, sentiment={type=string, index=not_analyzed}, word={type=string, index=not_analyzed}}}}]]",
"status": 400
}
这是我在sense console里的
PUT /pos/_mapping/gram
{
"mappings": {
"gram": {
"properties": {
"gram": {
"type": "string",
"fields": {
"gram_bm25": {
"type": "string", "similarity": "BM25"
},
"gram_lmd": {
"type": "string"
}
}
},
"sentiment": {
"type": "string", "index": "not_analyzed"
},
"word": {
"type": "string", "index": "not_analyzed"
}
}
}
}
}
- 索引的名称是'pos',我称类型为'gram'。
- 我创建了同名索引。
- 我已经使用 http://jsonlint.com/
验证了 json
- 我尝试在控制台中使用 XPUT,我得到了 'aknowleged' 响应,但是当我请求它时映射仍然是
{}
。
- this问题没有解决我的问题。我总是到处使用相同的名字。
有什么建议吗?
谢谢!
您只是 API 语法错误。基本上,您结合了两种不同的方法。
创建索引,然后应用映射:
DELETE /pos
PUT /pos
PUT /pos/gram/_mapping
{
"gram": {
"properties": {
"gram": {
"type": "string",
"fields": {
"gram_bm25": {
"type": "string",
"similarity": "BM25"
},
"gram_lmd": {
"type": "string"
}
}
},
"sentiment": {
"type": "string",
"index": "not_analyzed"
},
"word": {
"type": "string",
"index": "not_analyzed"
}
}
}
}
或者在创建索引时一次性完成:
DELETE /pos
PUT /pos
{
"mappings": {
"gram": {
"properties": {
"gram": {
"type": "string",
"fields": {
"gram_bm25": {
"type": "string",
"similarity": "BM25"
},
"gram_lmd": {
"type": "string"
}
}
},
"sentiment": {
"type": "string",
"index": "not_analyzed"
},
"word": {
"type": "string",
"index": "not_analyzed"
}
}
}
}
}
这是我使用的代码:
http://sense.qbox.io/gist/6d645cc069f5f0fcf14f497809f7f79aff7de161
我正在尝试使用 sense 为具有三个属性的索引创建映射。当我尝试创建它时,我得到以下响应
{
"error": "MapperParsingException[Root type mapping not empty after parsing! Remaining fields: [mappings : {gram={properties={gram={type=string, fields={gram_bm25={type=string, similarity=BM25}, gram_lmd={type=string}}}, sentiment={type=string, index=not_analyzed}, word={type=string, index=not_analyzed}}}}]]",
"status": 400
}
这是我在sense console里的
PUT /pos/_mapping/gram
{
"mappings": {
"gram": {
"properties": {
"gram": {
"type": "string",
"fields": {
"gram_bm25": {
"type": "string", "similarity": "BM25"
},
"gram_lmd": {
"type": "string"
}
}
},
"sentiment": {
"type": "string", "index": "not_analyzed"
},
"word": {
"type": "string", "index": "not_analyzed"
}
}
}
}
}
- 索引的名称是'pos',我称类型为'gram'。
- 我创建了同名索引。
- 我已经使用 http://jsonlint.com/ 验证了 json
- 我尝试在控制台中使用 XPUT,我得到了 'aknowleged' 响应,但是当我请求它时映射仍然是
{}
。 - this问题没有解决我的问题。我总是到处使用相同的名字。 有什么建议吗?
谢谢!
您只是 API 语法错误。基本上,您结合了两种不同的方法。
创建索引,然后应用映射:
DELETE /pos
PUT /pos
PUT /pos/gram/_mapping
{
"gram": {
"properties": {
"gram": {
"type": "string",
"fields": {
"gram_bm25": {
"type": "string",
"similarity": "BM25"
},
"gram_lmd": {
"type": "string"
}
}
},
"sentiment": {
"type": "string",
"index": "not_analyzed"
},
"word": {
"type": "string",
"index": "not_analyzed"
}
}
}
}
或者在创建索引时一次性完成:
DELETE /pos
PUT /pos
{
"mappings": {
"gram": {
"properties": {
"gram": {
"type": "string",
"fields": {
"gram_bm25": {
"type": "string",
"similarity": "BM25"
},
"gram_lmd": {
"type": "string"
}
}
},
"sentiment": {
"type": "string",
"index": "not_analyzed"
},
"word": {
"type": "string",
"index": "not_analyzed"
}
}
}
}
}
这是我使用的代码:
http://sense.qbox.io/gist/6d645cc069f5f0fcf14f497809f7f79aff7de161