Query_string is case sensitive


(Skrudox) #1
{
   "query":{
      "bool":{
         "must":[
            {
               "query_string":{
                  "query":"*sony*",
                  "analyze_wildcard":true,
                  "default_field":"title"
               }
            }
         ]
      }
   }
}

should this query above be case-insensitive? but in fact it is case-sensitive, is there any parameter I should add to make it case-insensitive?


(David Pilato) #2

I'd not use anything like a wildcard query. See https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-wildcard-query.html

Note that this query can be slow, as it needs to iterate over many terms. In order to prevent extremely slow wildcard queries, a wildcard term should not start with one of the wildcards * or ?.

Coming back to your question, documentation says about analyze_wildcard:

By default, wildcards terms in a query string are not analyzed. By setting this value to true, a best effort will be made to analyze those as well.


(Skrudox) #3

that best effort - means that it will search for entries with upper and lower case?


(David Pilato) #4

Depends on the analyzer you have for the fields I guess. What did you try so far and what does it give as a result?


(Skrudox) #5

I am trying to make it from the query side, not touching the inside backend-server settings cause they are mixed with django-haystack and I'am not sure on how it really works on the internal, and I didnt found anything about case-sensivity on the documentation, thats why I'am asking it here, does it even possible to make it case-insensitive at this way using only this query?


(David Pilato) #6

I did not try myself as never ever I'm using wildcard queries. What did you try so far and what is the result?

Could you provide a full recreation script as described in About the Elasticsearch category. It will help to better understand what you are doing. Please, try to keep the example as simple as possible.

A full reproduction script will help readers to understand, reproduce and if needed fix your problem.


(Skrudox) #7

the query above it is what I've tried, and my only question is how to force it search case-insensitive from the query side, thats all I ask, the only result is that does not return entries that are with different case, what isn't clear in my question?


(David Pilato) #8

Nothing is unclear. I totally understand the question. I don't have the answer and to get an answer I need to reproduce the problem.
To do that I need a script I can paste in Kibana to play around with your use case.

Again, I don't recommend doing the way you are doing it.


(system) #9

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