为现有索引启用_size

时间:2017-07-23 20:17:15

标签: elasticsearch elasticsearch-mapping

我需要为现有索引启用"_size"This question说它是可能的。但它没有提供如何做到的例子。

根据"Put Mapping API"我执行的查询

curl -XPUT "localhost:9200/my_index/_mapping/my_type?pretty" -d '{
      "properties": {
        "_size": {
          "enabled": true,
          "store" : true
        }
    }
}'

并收到错误:

{
  "error" : {
    "root_cause" : [
      {
        "type" : "mapper_parsing_exception",
        "reason" : "No type specified for field [_size]"
      }
    ],
    "type" : "mapper_parsing_exception",
    "reason" : "No type specified for field [_size]"
  },
  "status" : 400
}

我的错误是什么?请显示此查询的正确版本。

1 个答案:

答案 0 :(得分:1)

首先需要安装mapper-size plugin

bin/elasticsearch-plugin install mapper-size

然后你就可以像这样启用它:

PUT my_index
{
  "mappings": {
    "my_type": {
      "_size": {
        "enabled": true
      }
    }
  }
}

PUT my_index/_mapping/my_type
{
   "_size": {
     "enabled": true
   }
}
相关问题