Skip to content

Instantly share code, notes, and snippets.

@lukas-vlcek
Last active December 18, 2015 21:19
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 lukas-vlcek/5846552 to your computer and use it in GitHub Desktop.
Save lukas-vlcek/5846552 to your computer and use it in GitHub Desktop.
Ukázka ICU Collation pro češtinu. Předpokládá Elasticsearch 0.90.0 a nainstalovaný ICU plugin 1.9.0
#!/bin/sh
curl -X DELETE 'localhost:9200/i/'
curl -X POST 'localhost:9200/i/' -d '{
"settings" : {
"number_of_shards" : 1,
"number_of_replicas" : 0,
"analysis" : {
"analyzer" : {
"cs_icu_analyzer" : {
"type" : "custom",
"tokenizer" : "standard",
"filter" : ["cs_icu_collation"]
}
},
"filter" : {
"cs_icu_collation" : {
"type" : "icu_collation",
"language" : "cs"
}
}
}
},
"mappings" : {
"t" : {
"properties" : {
"text_icu" : { "type" : "string", "analyzer" : "cs_icu_analyzer" },
"text" : { "type" : "string" }
}
}
}
}'
curl -X POST 'localhost:9200/i/t/' -d '{ "text_icu" : "Celer", "text" : "Celer" }'
curl -X POST 'localhost:9200/i/t/' -d '{ "text_icu" : "Cypřiš", "text" : "Cypřiš" }'
curl -X POST 'localhost:9200/i/t/' -d '{ "text_icu" : "Cizrna", "text" : "Cizrna" }'
curl -X POST 'localhost:9200/i/t/' -d '{ "text_icu" : "Chřest", "text" : "Chřest" }'
curl -X POST 'localhost:9200/i/_refresh'
echo
echo; echo "Non ICU"
curl -X GET 'localhost:9200/i/t/_search?pretty=true' -d '{
"query" : { "match_all" : {} },
"sort" : [ "text" ]
}'
echo; echo "ICU"
curl -X GET 'localhost:9200/i/t/_search?pretty=true' -d '{
"query" : { "match_all" : {} },
"sort" : [ "text_icu" ]
}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment