Case insensitive search with fieldname.keyword


(Arcadix Infotech Pvt.Ltd) #1

Hi

I need search results with exact matching of word but it should be case insensitive.

"Abc","ABC","aBc" : all should come in result
but
"Abc Def", "ABC FG" : should not come (do not search for substring)

GET people/people/_search
{
  "query": {
    "bool": { 
      "must":[
          {
              "match": {
                "city.keyword": "York"
              }
          }
      ]   
    }
  }
}

Thanks
Aneesh L


(Val Crettaz) #2

You should try using match_phrase instead on the city field

GET people/people/_search
{
  "query": {
    "bool": { 
      "must":[
          {
              "match_phrase": {
                "city": "York"
              }
          }
      ]   
    }
  }
}

(Arcadix Infotech Pvt.Ltd) #3

image

But its giving New York also
I need only whole word match


(David Pilato) #4

I'd use a lowercase based analyzer in that case.


(Arcadix Infotech Pvt.Ltd) #5

You mean a settings/mapping change?


(David Pilato) #6

Yes.


(system) #7

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.