Elasticsearch 2.0:_id 不可配置
Elasticsearch 2.0: _id is not configurable
ES 2.0 刚刚发布。出于好奇,我针对 ES 2.0 测试了一直适用于 ES 1.7.3 的映射文件。我收到以下错误:
{
"error": {
"root_cause": [
{
"type": "mapper_parsing_exception",
"reason": "_id is not configurable"
}
],
"type": "mapper_parsing_exception",
"reason": "mapping [mydoctype]",
"caused_by": {
"type": "mapper_parsing_exception",
"reason": "_id is not configurable"
}
},
"status": 400
}
基本上,这个错误抱怨我的映射文件包含以下内容:
"mydoctype": {
"_id" : {
"path" : "id"
},
刚刚做了 google,但未能找到将 doc _id 设置为 ES 2.0 中索引文档的实际标识符的方法。我怎样才能做到这一点?
感谢任何指点和输入!
根据 announcing blog post,您现在需要在索引查询中明确设置值,即
curl -XPUT localhost:9200/your_index/your_type/YOUR_ID -d '{...}'
^
|
set your id here
或者在您的 _bulk
查询中:
curl -XPOST localhost:9200/your_index/your_type/_bulk -d '
{"index": {"_id": "YOUR_ID"}}
{...} ^
' |
set your id here
ES 2.0 刚刚发布。出于好奇,我针对 ES 2.0 测试了一直适用于 ES 1.7.3 的映射文件。我收到以下错误:
{
"error": {
"root_cause": [
{
"type": "mapper_parsing_exception",
"reason": "_id is not configurable"
}
],
"type": "mapper_parsing_exception",
"reason": "mapping [mydoctype]",
"caused_by": {
"type": "mapper_parsing_exception",
"reason": "_id is not configurable"
}
},
"status": 400
}
基本上,这个错误抱怨我的映射文件包含以下内容:
"mydoctype": {
"_id" : {
"path" : "id"
},
刚刚做了 google,但未能找到将 doc _id 设置为 ES 2.0 中索引文档的实际标识符的方法。我怎样才能做到这一点?
感谢任何指点和输入!
根据 announcing blog post,您现在需要在索引查询中明确设置值,即
curl -XPUT localhost:9200/your_index/your_type/YOUR_ID -d '{...}'
^
|
set your id here
或者在您的 _bulk
查询中:
curl -XPOST localhost:9200/your_index/your_type/_bulk -d '
{"index": {"_id": "YOUR_ID"}}
{...} ^
' |
set your id here