Is it possible : Terms filter by ignorecase?

I'm new in elastic search...can anyone help to create a query that will search multiple values with ignoring case.
if I use lower case then below search query is working properly but when I use UPPER case it is not returning data so do I have to convert into lower 1st or is there any way to search by ignoring the case?

> {
>   "query": {
>     "constant_score": {
>       "filter": {
>         "bool": {
>           "must": [
>               {
>               "terms": {
>                 "shape": [
>                   "ROUND",
>                   "HEART"
>                 ]
>               }
>             }
>           ]
>         }
>       }
>     }
>   }
> }

Using a match query will analyze the data in the same way as the text was analyzed, usually. Have a look at analyzers for text fields and then read about normalizers for keyword fields.

I don't believe there is a way to use the terms query with analyzed terms though. But it is fine to use bool with should clauses, usually. terms is required only if you have many, many terms to match. If you don't it is automatically rewritten to bool with should clauses, actually.

1 Like

@nik9000 Thanks for reply :slight_smile:

Yes, I have many terms to match.

I'm little bit aware of normalizers/analyzers that they are converting into lower case before indexing it and before executing query etc.
And its good to know that terms will automatically be rewritten into bool with should clauses.

Is there any fields to ignore case or something else?

They can do that if you set them up to do it.

No. At the moment you either use terms and lowercase on your side or use match inside bool. I don't know off hand if we've talked through a match-like thing that works using terms.

Let say I'm finding an object based on its shape(round, heart, pear...)
So for multiple values how can I use match?

@nik9000 can you suggest performance wise query using terms is better or using(match) below example,

  "size": 1000,
  "query": {
    "constant_score": {
      "filter": {
        "bool": {
          "must": [  {
              "match": {
                  "round heart"

terms is likely going to be faster every time but it is worth benchmarking with real data to see how much faster. Even if that benchmark is just a quick and dirty bash script with ab. Then you'll know how much faster. And whether or not it is worth adding something to ES. If it turns out that it is much faster for you use case we'd certainly consider adding it. I would, at least.

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