Skip to content

Instantly share code, notes, and snippets.

@emilis
Created April 4, 2012 13:58
Show Gist options
  • Save emilis/2301281 to your computer and use it in GitHub Desktop.
Save emilis/2301281 to your computer and use it in GitHub Desktop.
Hunspell_lt for ElasticSearch
{
"index": {
"mappings": {
"item": {
"properties": {
"name": {
"type": "string",
"analyzer": "text_lt"
}
}
}
},
"analysis": {
"filter": {
"snowball_lt": {
"type": "snowball",
"language": "Lithuanian"
},
"hunspell_lt": {
"locale": "lt_LT",
"ignoreCase": true,
"type": "hunspell"
}
},
"analyzer": {
"lowercase_keyword": {
"filter": [ "lowercase" ],
"type": "custom",
"tokenizer": "keyword"
},
"text_lt": {
"filter": [ "standard", "lowercase", "stop", "hunspell_lt" ],
"type": "custom",
"tokenizer": "standard"
}
}
}
}
}
echo -e "Deleting index testas"
curl -XDELETE 'http://localhost:9200/testas/'
echo -e "\nCreating index testas"
curl -XPUT 'http://localhost:9200/testas/' -d @test-index.json
sleep 1
echo -e "\nAdding test item"
curl -XPUT 'http://localhost:9200/testas/item/1' -d @test-item.json
sleep 1
echo -e "\nSearching for 'skani':"
curl 'http://localhost:9200/testas/item/_search?q=name:skani'
echo -e "\nSearching for 'varškė':"
curl 'http://localhost:9200/testas/item/_search?q=name:varškė'
echo ""
{"name":"Skani varškė"}
@emilis
Copy link
Author

emilis commented Apr 4, 2012

$ ./test-index.sh output:

emilis@emilis-laptop:~/work/2301281$ ./test-index.sh 
Deleting index testas
{"ok":true,"acknowledged":true}
Creating index testas
{"ok":true,"acknowledged":true}
Adding test item
{"ok":true,"_index":"testas","_type":"item","_id":"1","_version":1}
Searching for 'skani':
{"took":2,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":1,"max_score":0.13561106,"hits":[{"_index":"testas","_type":"item","_id":"1","_score":0.13561106, "_source" : {"name":"Skani varškė"}}]}}
Searching for 'varškė':
{"took":2,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":0,"max_score":null,"hits":[]}}

@emilis
Copy link
Author

emilis commented Apr 4, 2012

Elasticsearch server output:

emilis@emilis-laptop:~/dwn/servers/elasticsearch-0.18.7$ bin/elasticsearch -f
[2012-04-04 17:05:41,251][INFO ][node                     ] [Hogan, Harold "Happy"] {0.18.7}[12966]: initializing ...
[2012-04-04 17:05:41,262][INFO ][plugins                  ] [Hogan, Harold "Happy"] loaded [analysis-hunspell], sites []
[2012-04-04 17:05:43,265][INFO ][node                     ] [Hogan, Harold "Happy"] {0.18.7}[12966]: initialized
[2012-04-04 17:05:43,266][INFO ][node                     ] [Hogan, Harold "Happy"] {0.18.7}[12966]: starting ...
[2012-04-04 17:05:43,358][INFO ][transport                ] [Hogan, Harold "Happy"] bound_address {inet[/0:0:0:0:0:0:0:0:9300]}, publish_address {inet[/192.168.1.103:9300]}
[2012-04-04 17:05:46,403][INFO ][cluster.service          ] [Hogan, Harold "Happy"] new_master [Hogan, Harold "Happy"][Q-mkokDvRWmHgtSkkOW4og][inet[/192.168.1.103:9300]], reason: zen-disco-join (elected_as_master)
[2012-04-04 17:05:46,471][INFO ][discovery                ] [Hogan, Harold "Happy"] elasticsearch/Q-mkokDvRWmHgtSkkOW4og
[2012-04-04 17:05:46,482][INFO ][http                     ] [Hogan, Harold "Happy"] bound_address {inet[/0:0:0:0:0:0:0:0:9200]}, publish_address {inet[/192.168.1.103:9200]}
[2012-04-04 17:05:46,487][INFO ][node                     ] [Hogan, Harold "Happy"] {0.18.7}[12966]: started
[2012-04-04 17:05:46,493][INFO ][gateway                  ] [Hogan, Harold "Happy"] recovered [0] indices into cluster_state
[2012-04-04 17:06:18,611][INFO ][cluster.metadata         ] [Hogan, Harold "Happy"] [testas] creating index, cause [api], shards [5]/[1], mappings []
[2012-04-04 17:06:20,112][INFO ][cluster.metadata         ] [Hogan, Harold "Happy"] [testas] update_mapping [item] (dynamic)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment