Forked from justinvw/es_simple_autocomplete_example_config.sh
Created
January 31, 2014 12:38
-
-
Save blennocleofas/8731411 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# Delete the possibly existing autocomplete test index | |
curl -X DELETE localhost:9200/autocomplete_test | |
# Put the config of the autocomplete index | |
curl -X PUT localhost:9200/autocomplete_test -d ' | |
{ | |
"settings" : { | |
"index" : { | |
"analysis" : { | |
"analyzer" : { | |
"autocomplete_analyzer" : { | |
"type" : "custom", | |
"tokenizer" : "lowercase", | |
"filter" : ["asciifolding", "title_ngram"] | |
} | |
}, | |
"filter" : { | |
"title_ngram" : { | |
"type" : "nGram", | |
"min_gram" : 3, | |
"max_gram" : 5 | |
} | |
} | |
} | |
} | |
}, | |
"mappings": { | |
"city": { | |
"properties": { | |
"city": { | |
"type": "string", | |
"analyzer": "autocomplete_analyzer", | |
"boost": 10 | |
} | |
} | |
} | |
} | |
} | |
' | |
# Show how query input is analyzed | |
curl "http://localhost:9200/autocomplete_test/_analyze?text=Ouderkerk+aan+de+Amstel&analyzer=autocomplete_analyzer&pretty=True" | |
# Post some sample documents | |
curl -X POST "http://localhost:9200/autocomplete_test/city" -d '{ "city" : "Amsterdam" }' | |
curl -X POST "http://localhost:9200/autocomplete_test/city" -d '{ "city" : "Amstelveen" }' | |
curl -X POST "http://localhost:9200/autocomplete_test/city" -d '{ "city" : "Ouderkerk aan de Amstel" }' | |
curl -X POST "http://localhost:9200/autocomplete_test/city" -d '{ "city" : "Alphen aan den Rijn" }' | |
curl -X POST "http://localhost:9200/autocomplete_test/city" -d '{ "city" : "Den Haag" }' | |
curl -X POST "http://localhost:9200/autocomplete_test/city" -d '{ "city" : "Rotterdam" }' | |
curl -X POST "http://localhost:9200/autocomplete_test/city" -d '{ "city" : "Groningen" }' | |
curl -X POST "http://localhost:9200/autocomplete_test/city" -d '{ "city" : "Castelré" }' | |
curl -X POST "http://localhost:9200/autocomplete_test/city" -d '{ "city" : "Etten-Leur" }' | |
curl -X POST "http://localhost:9200/autocomplete_test/city" -d '{ "city" : "Babyloniënbroek" }' | |
# Make sure everything is indexed | |
curl -X POST "http://localhost:9200/autocomplete_test/_refresh" | |
# Perform some searches | |
curl "http://localhost:9200/autocomplete_test/_search?q=city:Ams&pretty=True" | |
curl "http://localhost:9200/autocomplete_test/_search?q=city:aan+de&pretty=True" | |
curl "http://localhost:9200/autocomplete_test/_search?q=city:etten&pretty=True" | |
curl "http://localhost:9200/autocomplete_test/_search?q=city:lre&pretty=True" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment