-
-
Save ribugent/ad842294f4f9380da9c9 to your computer and use it in GitHub Desktop.
Elasticsearch query with wildcard not working with icu_collation filter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
echo "==== Creating index ====" | |
curl -XPUT 'http://localhost:9200/icu_wildcard/?pretty=1' -d '{ | |
"settings" : { | |
"index" : { | |
"number_of_shards" : 1, | |
"number_of_replicas" : 1 | |
}, | |
"analysis" : { | |
"analyzer":{ | |
"unicode_l1": { | |
"char_filter": [ | |
"icu_normalizer_nfc" | |
], | |
"tokenizer": "icu_tokenizer", | |
"filter": [ | |
"icu_collation_primary_filter" | |
] | |
} | |
}, | |
"char_filter": { | |
"icu_normalizer_nfc": { | |
"type": "icu_normalizer", | |
"name": "nfc" | |
} | |
}, | |
"filter": { | |
"icu_collation_primary_filter": { | |
"type": "icu_collation", | |
"strength": "primary" | |
} | |
} | |
} | |
} | |
}' | |
curl -XPUT 'http://localhost:9200/icu_wildcard/_mapping/test?pretty=1' -d ' | |
{ | |
"dynamic": false, | |
"_source": { | |
"enabled": false | |
}, | |
"properties": { | |
"first_name_unicode": { | |
"type": "string", | |
"analyzer": "unicode_l1" | |
}, | |
"first_name_standard": { | |
"type": "string", | |
"analyzer": "standard" | |
} | |
} | |
} | |
}' | |
echo "==== Adding doc ====" | |
curl -XPUT 'http://localhost:9200/icu_wildcard/test/1?pretty=1' -d '{ | |
"first_name_unicode" : "ABCDEFGHIJKLabcdefghijkl", | |
"first_name_standard" : "ABCDEFGHIJKLabcdefghijkl" | |
}' | |
curl -XPOST 'http://localhost:9200/icu_wildcard/_flush?pretty=1' | |
echo "==== Search on icu field ====" | |
curl -XGET 'http://localhost:9200/icu_wildcard/test/_search?q=first_name_unicode:abcdef*&analyze_wildcard=true&pretty=1' | |
echo "==== Search on standard field ====" | |
curl -XGET 'http://localhost:9200/icu_wildcard/test/_search?q=first_name_standard:abcdef*&analyze_wildcard=true&pretty=1' | |
echo "==== Query explain ====" | |
curl -XGET 'http://localhost:9200/icu_wildcard/test/_validate/query?explain&q=first_name_unicode:abcdef*&analyze_wildcard=true&pretty=1' | |
curl -XGET 'http://localhost:9200/icu_wildcard/test/_validate/query?explain&q=first_name_standard:abcdef*&analyze_wildcard=true&pretty=1' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment