如何在elasticsearch上添加更多属性

时间:2017-07-13 13:43:10

标签: elasticsearch

elasticsearch版本是2.4.0

这是我的弹性搜索索引映射

curl -XPUT 'http://XXX.X.XX.XXX:XXXXX/stores/' -d '{
    "settings" : {
        "index" : {
            "number_of_shards" : 3, 
            "number_of_replicas" : 1 
        }
    },
    "mappings" : {
        "store" : {
          "_all":{ "enabled": true  },
          "properties":{
            "url" : { "type" : "string", "analyzer" : "simple", "boost" : 3 },
            "title" : { "type" : "string", "boost" : 2 },
            "description" : { "type" : "string" },
            "keywords" : { "type" : "string" },
            "time_updated" : { "type" : "integer", "index" : "not_analyzed", "include_in_all": true },
            "time_added" : { "type" : "integer", "index" : "not_analyzed", "include_in_all": true }
          }
        }
    } }'

已经创建了这个映射 我想添加更多属性,但应分析这些属性。

我是弹性搜索的新手,请帮帮我

1 个答案:

答案 0 :(得分:0)

仍然使用PUT Index API

PUT stores
{
  "mappings": {
    "store": {
      "properties": {
        "new_field": {
            "type": "keyword"
        }
      }
    }
  }
}

更新字段映射

https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-put-mapping.html#updating-field-mappings