Reputation: 12740
First of all I'm completly new to ES. I created ES search criteria below for searching items which works fine but what I now need is, I want to turn make field into case-insensitive so that the search result would be the same for hello
, HeLlo
, HELLO
so on.
I've read post below couldn't quiet apply to my example below because of my very limited knowledge:
Removing not_analyzed
from make doesn't help.
'indexes' => [
'my_project' => [
'client' => 'default',
'index_name' => 'hello',
'settings' => [
'index' => [
'analysis' => [
'analyzer' => [
'snowball_analyzer' => [
'type' => 'snowball',
'language' => 'English',
],
],
],
],
],
'types' => [
'item' => [
'mappings' => [
'uuid' => ['type' => 'string', 'index' => 'not_analyzed'],
'name' => ['type' => 'string', 'boost' => 8, 'analyzer' => 'snowball_analyzer'],
'make' => ['type' => 'string', 'index' => 'not_analyzed'],
]
],
],
],
],
These is the query that I created:
1
{
"query": {
"filtered": {
"query": {
"bool": {
"must": [
{
"term": {
"make": "HeLlo"
}
}
]
}
}
}
}
}
Upvotes: 0
Views: 691
Reputation: 12740
I went thru the answer in the first link I posted with my eyes open this time and it solved my problem too so my case-insensitive working example is:
{
"query": {
"filtered": {
"query": {
"bool": {
"must": [
{
"query_string": {
"query": "HeLlo*"
}
}
]
}
}
}
}
}
Upvotes: 0
Reputation: 4265
You have to add the "lowercase" filter. Here is an extract for a similar configuration I use:
settings:
index:
analysis:
analyzer:
custom_search_analyzer:
type: custom
tokenizer: standard
filter: [stopwords, asciifolding ,lowercase, snowball, elision, worddelimiter]
In your case, I guess you should change like this:
...
'settings' => [
'index' => [
'analysis' => [
'analyzer' => [
'snowball_analyzer' => [
'type' => 'snowball',
'language' => 'English',
'filter' => [ 'lowercase' ]
],
],
],
],
],
...
Upvotes: 0