Skip to content

Instantly share code, notes, and snippets.

@imotov
Created November 1, 2012 14:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save imotov/3993902 to your computer and use it in GitHub Desktop.
Save imotov/3993902 to your computer and use it in GitHub Desktop.
curl -XDELETE 'http://localhost:9200/test-idx'
echo
curl -XPUT 'http://localhost:9200/test-idx'
echo
echo
echo "**** Standard analyzer ****"
curl 'http://localhost:9200/test-idx/_analyze?pretty=true' -d 'This is a test of vamsikrishna@gmail.com'
echo
curl -XDELETE 'http://localhost:9200/test-idx'
echo
echo
echo "**** Email analyzer ****"
curl -XPUT 'http://localhost:9200/test-idx' -d '{
"settings" : {
"index": {
"analysis" :{
"analyzer": {
"default": {
"type" : "custom",
"tokenizer" : "uax_url_email",
"filter" : ["standard", "lowercase", "stop"]
}
}
}
}
}
}
'
echo
curl 'http://localhost:9200/test-idx/_analyze?pretty=true' -d 'This is a test of vamsikrishna@gmail.com'
echo
curl -XDELETE 'http://localhost:9200/test-idx'
echo
curl -XPUT 'http://localhost:9200/test-idx' -d '{
"mappings" : {
"doc" : {
"properties" : {
"name" : {"type": "string", "index": "analyzed"},
"email" : {"type": "string", "index": "not_analyzed", "include_in_all": false}
}
}
}
}
'
echo
curl -XPUT localhost:9200/test-idx/doc/1 -d '{
"name": "Elastic Search",
"email": "search@elasticsearch.org"
}'
echo
curl -XPUT localhost:9200/test-idx/doc/2 -d '{
"name": "Lucene",
"email": "search@apache.org"
}'
echo
curl -XPOST localhost:9200/test-idx/_refresh
curl 'http://localhost:9200/test-idx/_search?pretty=true' -d '{
"query" : {
"query_string" : {
"query" : "search",
"fields" : ["_all", "email"]
}
}
}'
echo
curl 'http://localhost:9200/test-idx/_search?pretty=true' -d '{
"query" : {
"query_string" : {
"query" : "search@apache.org",
"default_operator": "AND",
"fields" : ["_all", "email"]
}
}
}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment