Skip to content

Instantly share code, notes, and snippets.

@SeventhHelix
Created August 13, 2013 00:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SeventhHelix/911789353a91de6810f4 to your computer and use it in GitHub Desktop.
Save SeventhHelix/911789353a91de6810f4 to your computer and use it in GitHub Desktop.
curl -XDELETE 'localhost:9200/test'
echo "Creating new ElasticSearch index..."
curl -XPUT 'localhost:9200/test' -d '
{
"mappings" : {
"user" : {
"properties" : {
"emailAddress" : {
"analyzer": "string_lowercase",
"type" : "string"
}
}
}
},
"settings" : {
"analysis" : {
"analyzer" : {
"string_lowercase": {
"tokenizer" : "keyword",
"filter" : "lowercase"
}
}
}
}
}
'
echo
curl -XGET 'http://localhost:9200/_cluster/health?wait_for_status=yellow&timeout=5s';echo
curl -XPUT 'localhost:9200/test/user/1?refresh' -d '
{
"emailAddress": "PrettyLongEmailAddress@foo.com"
}'
echo
curl -XGET 'localhost:9200/test/user/_search?pretty=1' -d '
{
"query": {
"bool": {
"must": [ {
"query_string": {
"fields": [ "emailAddress" ],
"fuzzy_min_sim": 0.01,
"fuzzy_prefix_length": 2,
"query": "PrettyLongEmailAddress@foz.zzz~"
}
} ]
}
}
}'
echo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment