Enable _size for exist index

2019-08-21 09:14发布

I need to enable "_size" for an exist index. This question talks that it's possible. But it provides no example how to do it.

According to "Put Mapping API" I executed query

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

and got error:

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

What my mistake is? Please, show the correct version of this query.

1条回答
何必那么认真
2楼-- · 2019-08-21 09:45

You first need to install the mapper-size plugin:

bin/elasticsearch-plugin install mapper-size

Then you'll be able to enable it like this:

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

or

PUT my_index/_mapping/my_type
{
   "_size": {
     "enabled": true
   }
}
查看更多
登录 后发表回答