How to set a lowercase analyzer


(Gili Sade) #1

HI
i have an index that containes a field with the value test.
somtimes the field containes : "Test" or "TEST" or "test"

i need to do a bool query that matches all three ocations.
i read that i can do it with lowercase analyzer
i could not figure out how to set it up

Any help?


(David Pilato) #2

Elasticsearch does that by default with the standard analyzer.


(Gili Sade) #3

yes eventually i managed to do it
but the field type must be text and analyzed
thank :slight_smile:

BTW
is there a way to query (with bool) incasesensitive?


(Gili Sade) #4

i actually managed to do that with bool and query string:

  "query": {
    "bool": {
      "must": [
        {
          "query_string": {
            "query": "FIELD:*STRING*",
            "analyze_wildcard": true
          }
        }
        ]
    }
   }

this will search for the string in a non-case sensitive way (for an analyzed field)


(David Pilato) #5

Note that using a leading wildcard is really discouraged.

Why not using a match query instead?


(Gili Sade) #6

To be honest
I looked how kibana does the same request and it uses query_string
what's the benefit of using match query over query_string in this case?


(David Pilato) #7

I see. query_string is ok but I'd not use wildcard if possible.


(Gili Sade) #8

I'm afraid it is not possible.
The entire purpose of the program using this query is to search a string or a part of a string in a certain field (which can be very large) - so we must use wildcards .


(David Pilato) #9

Ngrams wouldn't work?


(system) #10

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