0

Can I use wildcard pattern to determine index analyzer for elasticsearch?

For example: "properties":

{ 
    "0_*" : {"type": "string", "index_analyzer": "standard" } , 
    "1_*" : {"type": "string", "index_analyzer": "my_analyzer"}
}

So now if there is a new field when I index the document like

{
    "0_title" : "some string", // should use standard analyzer
    "1_title" : "my anazlyer string" // should use my_analyzer
}

Is there anyway to achieve this?

1 Answer 1

1

Yes , all you need to use is the index template. You can find more information on dynamic template here Using index template , you can inject a rule as follows -

{
  "person": {
    "dynamic_templates": [
      {
        "template_0": {
          "match": "0_*",
          "mapping": {
            "type": "string",
            "index_analyzer": "standard"
          }
        }
      },
      {
        "template_1": {
          "match": "1_*",
          "mapping": {
            "type": "string",
            "index_analyzer": "my_analyzer"
          }
        }
      }
    ]
  }
}
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.