Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Norwegian Bokmål sort with Elasticsearch
# Norwegian Bokmål sort with ICU
# ES 0.90.2
# ./bin/plugin --install elasticsearch/elasticsearch-analysis-icu/1.10.0
curl -XDELETE 'localhost:9200/test'
curl -XPUT 'localhost:9200/test' -d '
{
"settings" : {
"index" : {
"analysis" : {
"filter" : {
"bokmal": {
"type" : "icu_collation",
"language" : "nb"
}
},
"analyzer" : {
"bokmalAnalyzer" : {
"type" : "custom",
"tokenizer" : "keyword",
"filter" : "bokmal"
}
}
}
}
},
"mappings" : {
"_default_": {
"properties" : {
"name" : {
"type" : "string",
"analyzer" : "bokmalAnalyzer"
}
}
}
}
}
'
curl -XPUT 'localhost:9200/test/data/1' -d '
{
"name" : "åges plateselskap as"
}
'
curl -XPUT 'localhost:9200/test/data/2' -d '
{
"name" : "ølen fiskelag"
}
'
curl -XPUT 'localhost:9200/test/data/3' -d '
{
"name" : "æ vil ha dæ"
}
'
curl -XPUT 'localhost:9200/test/data/4' -d '
{
"name" : "yara international"
}
'
curl -XGET 'localhost:9200/test/_refresh'
# without sort
curl -XGET 'localhost:9200/test/data/_search?pretty' -d '
{
"query" : {
"match_all": {
}
}
}'
# with sort
curl -XGET 'localhost:9200/test/data/_search?pretty' -d '
{
"query" : {
"match_all": {
}
},
"sort" : {
"name" : {
"order" : "desc"
}
}
}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment