-
-
Save lukleh/851473 to your computer and use it in GitHub Desktop.
ElasticSearch mapping for language stemming
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo "Delete DBs" | |
curl -s -X DELETE 'http://localhost:9200/test_twitter_cs/' | |
echo | |
curl -s -X DELETE 'http://localhost:9200/test_twitter_en/' | |
echo | |
echo "Create Czech index" | |
curl -s -X PUT 'http://localhost:9200/test_twitter_cs/' | |
echo | |
echo "Create English index" | |
curl -s -X PUT 'http://localhost:9200/test_twitter_en/' | |
echo | |
echo "Create mapping for Czech documents" | |
curl -s -X PUT 'http://localhost:9200/test_twitter_cs/_mapping' -d ' | |
{ | |
"status" : { | |
"properties" : { | |
"text" : { | |
"type" : "multi_field", | |
"fields" : { | |
"text" : {"type" : "string", "index" : "analyzed", "analyzer" : "czech"}, | |
"exact" : {"type" : "string", "index" : "analyzed", "analyzer" : "simple"} | |
} | |
} | |
} | |
} | |
}' | |
echo | |
echo "Refresh indices" | |
curl -s -X POST 'http://localhost:9200/test_twitter_cs/_refresh' | |
echo | |
echo "Create documents" | |
curl -s -X POST 'http://localhost:9200/test_twitter_cs/status' -d '{"status":{"text":"stromeček"}, id:1}' | |
echo | |
curl -s -X POST 'http://localhost:9200/test_twitter_cs/status' -d '{"status":{"sub_tweet":{"text":"stromeček"}}, id:4}' | |
echo | |
curl -s -X POST 'http://localhost:9200/test_twitter_cs/status' -d '{"text":"stromeček", id:3}' | |
echo | |
curl -s -X POST 'http://localhost:9200/test_twitter_cs/status' -d '{"tweet":{"text":"stromeček"}, id:2}' | |
echo | |
curl -s -X POST 'http://localhost:9200/test_twitter_cs/status' -d '{"status":{"text":"stromečkove"}, id:5}' | |
echo | |
curl -s -X POST 'http://localhost:9200/test_twitter_cs/status' -d '{"text":"stromečkove"}, id:6}' | |
echo | |
curl -s -X POST 'http://localhost:9200/test_twitter_cs/_refresh' | |
echo | |
echo 'Create database "twitter" as an alias for "test_twitter_cs" and "test_twitter_en"' | |
curl -s -X POST 'http://localhost:9200/_aliases' -d ' | |
{ | |
"actions" : [ | |
{ "add" : { "index" : "test_twitter_cs", "alias" : "test_twitter" } }, | |
{ "add" : { "index" : "test_twitter_en", "alias" : "test_twitter" } } | |
] | |
}' | |
echo | |
echo "Search for phrase in Czech documents" | |
curl -s -X GET 'http://localhost:9200/test_twitter/_search?pretty=true&q=text:strome%C4%8Dky' | |
echo | |
curl -s -X GET 'http://localhost:9200/test_twitter/_search?pretty=true&q=status.text:strome%C4%8Dky' | |
echo | |
curl -s -X GET 'http://localhost:9200/test_twitter/_search?pretty=true&q=tweet.text:strome%C4%8Dky' | |
echo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment