Skip to content

Instantly share code, notes, and snippets.

@ribugent
Last active February 25, 2016 08:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ribugent/ad842294f4f9380da9c9 to your computer and use it in GitHub Desktop.
Save ribugent/ad842294f4f9380da9c9 to your computer and use it in GitHub Desktop.
Elasticsearch query with wildcard not working with icu_collation filter
#!/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