heinob
heinob

Reputation: 19464

Find uppercase strings with wildcard

I have a field my_field that is defined like this:

"properties" : {
    ...
    "my_field" : { "type" : "string", "store" : "no", "index" : "not_analyzed" },
    ...
}

All lowercase strings that are stored in that field can be found with wildcard:

i.e. kindergarten can be found with my_field:kinder*

but all uppercase strings cannot be found with wildcard:

i.e. KINDERGARTEN can neither be found with myfield:KINDER* nor with my_field:kinder*

Is that the expected behaviour or am I doing something wrong?

Upvotes: 1

Views: 838

Answers (2)

Srost
Srost

Reputation: 139

You must set lowercase_expanded_terms to false in order to do case-sensitive search with wildcards. Like this: http://localhost:9200/test/_search?lowercase_expanded_terms=false&q=my_field:KINDER*

Upvotes: 1

belo
belo

Reputation: 108

I did quick test and everything looks correct to me.

I would try to test analysis on that field using /_analyze API to see that values really aren't lowercased.

curl -XPOST 'http://localhost:9200/test/_analyze?field=my_field' -d {
    "test": "This Should Be Single Token"
}

Or try Index Termlist Plugin to see what tokens are actually stored in that field.

Upvotes: 0

Related Questions