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"
    },

刚刚谷歌搜索并没有找到将 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

关于Elasticsearch 2.0 : _id is not configurable,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/33428976/

10-16 22:38