1
votes

I forced with problem searching by email. Email has keyword type. Some users add an email with capital letters, so I can't search all of them via term construction. Locally I tried to change keyword to text but the new problem has appeared. Example: search by [email protected] - elastic splits this email to several parts and returns wrong results: [email protected], [email protected] and etc. What is the best way to do this kind of search via elastic? (it would be better to avoid full reindex)

ElasticSearch 6.6.1

"mappings": {
        "_doc": {
            "properties": {
                "email": {
                    "type": "text"
                }
1

1 Answers

1
votes

You will have to reindex your index (or add a secondary field with unsensitive case analyzer and query on this field, delete the first field and rename fieldname, but it will be a little more complicated maybe ). Indeed, as if you could add an analyzer by closing and reopening index, elastic have to reindex older data.

For the analyzer a lowercase should be ok in your case.

    "analyzer":{
      "analyzer_lowcase":{
        "tokenizer":"keyword",
        "filter":"lowercase"
      }