Skip to content

Instantly share code, notes, and snippets.

@lukas-vlcek lukas-vlcek/gist:5846552
Last active Dec 18, 2015

Embed
What would you like to do?
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
You can’t perform that action at this time.