Home > other >  Elastic Search Lowercase analyser does not return search result
Elastic Search Lowercase analyser does not return search result

Time:03-03

I have a text based index like below. I am trying to maintain both exact search and ambiguous search based on tokens based on user input. While text based search works fine(partial search) when it comes to term search it returns data iff case is the same. I did try adding a lowercase filter based analyzer but it does not help. What can I do here?

Mappings:

"project_title": {
    "type": "text",
    "fields": {
      "keyword": {
        "type": "keyword",
        "ignore_above": 256
      }
    }
  },
  "projectabstract": {
    "type": "text",
    "fields": {
      "keyword": {
        "type": "keyword",
        "ignore_above": 256
      }
    }
  },

New index based on lowercase analyzer:

PUT /project_term_search_text_analyzer
{
  "settings": {
    "analysis": {
      "analyzer": {
        "rebuilt_standard": {
          "tokenizer": "standard",
          "filter": [
            "lowercase"       
          ]
        }
      }
    }
  },
  "mappings": {"project_title": {
    "type": "text",
    "fields": {
      "keyword": {
        "type": "keyword",
        "ignore_above": 256
      }
    }
  },
  "projectabstract": {
    "type": "text",
    "fields": {
      "keyword": {
        "type": "keyword",
        "ignore_above": 256
      }
    }
  },}

How should I update my index to work in both cases.

CodePudding user response:

You need to use the normalizer which works on the keyword fields. You can also customize your normalizer like analyzer, In the link you can find the relevant example with lowercase filter, which would solve your issue.

  • Related