0

I want to write a template in elasticsearch that changes all strngs to not analyzed. The official documentation shows that I can do that using

"properties": {
        "host_name": {
          "type": "string",
          "index": "not_analyzed"
        },
        "created_at": {
          "type": "date",
          "format": "EEE MMM dd HH:mm:ss Z YYYY"
        }
      }

But the problem here is that I need to do this for every field like it is done here for host_name. I tried using _all and __all but it did not seem to work. How can I change all the strings to not analyzed using a custom template?

2
  • For an already existent index? If so, not possible. Commented Apr 9, 2016 at 13:26
  • I am currently setting up and testing the server, so the data indexed is hardly 5 documents.... It wouldn't be much of a problem! Commented Apr 9, 2016 at 18:03

1 Answer 1

2

For an already existent index, you cannot change the mapping of the already existent fields and, even if you could, you need to reindex all documents so that they can obey the new mapping rules.

Otherwise, if you just create the index:

PUT /_template/not_analyzed_strings
{
  "template": "xxx-*",
  "order": 0,
  "mappings": {
    "_default_": {
      "dynamic_templates": [
        {
          "string_fields": {
            "mapping": {
              "index": "not_analyzed",
              "type": "string"
            },
            "match_mapping_type": "string",
            "match": "*"
          }
        }
      ]
    }
  }
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.