Elasticsearch - change field from not_analyzed for analysis

Is it possible to change the property of an existing field from not_analyzedto analyzed?

If not, what can I do to store all my documents in the store?

I cannot delete the mappings (because then all the documents will disappear), and I need this old field to be parsed.

+4
source share
2 answers

You cannot modify an existing field, however you can either create another field or add a subfield to the field not_analyzed.

I am going to use the latest solution. So, first add a new subfield to an existing field, for example:

curl -XPUT localhost:9200/index/_mapping/type -d '{
    "properties": {
        "your_field": {
            "type": "string",
            "index": "not_analyzed",
            "fields": {
                "sub": {
                    "type": "string"
                }
            }
        }
    }
}'

your_field.sub ( ) your_field ( not_analyzed)

, . ES 2.3, Reindex API

curl -XPUT localhost:9200/_reindex -d '{
  "source": {
    "index": "index"
  },
  "dest": {
    "index": "index"
  },
  "script": {
    "inline": "ctx._source.your_field = ctx._source.your_field"
  }
}'

Logstash, ,

input {
  elasticsearch {
   hosts => "localhost:9200"
   index => "index"
   docinfo => true
  }
}
filter {
 mutate {
  remove_field => [ "@version", "@timestamp" ]
 }
}
output {
 elasticsearch {
   hosts => ["localhost:9200"]
   manage_template => false
   index => "%{[@metadata][_index]}"
   document_type => "%{[@metadata][_type]}"
   document_id => "%{[@metadata][_id]}"
 }
}
+9

All Articles