Skip to content

Instantly share code, notes, and snippets.

@dqduc
Created February 9, 2015 07:49
Show Gist options
  • Save dqduc/1d501fbf01cf58a1cb06 to your computer and use it in GitHub Desktop.
Save dqduc/1d501fbf01cf58a1cb06 to your computer and use it in GitHub Desktop.
curl -XDELETE localhost:9200/myindex
curl -XPUT localhost:9200/myindex -d '
{
"settings" : {
"index":{
"number_of_replicas":0,
"number_of_shards":1,
"analysis":{
"analyzer":{
"string_lowercase":{
"type" : "custom",
"tokenizer" : "keyword",
"filter": ["lowercase"]
}
}
}
}
},
"mappings" : {
"mytype":{
"properties":{
"Id":{
"type":"string",
"search_analyzer":"string_lowercase",
"index_analyzer":"string_lowercase"
}
}
}
}
}'
# Now, index data
curl -XPOST "http://localhost:9200/_bulk?pretty=true" -d '
{ "index" : { "_index" : "myindex", "_type" : "mytype", "_id" : "1" } }
{ "Id" : "2C4294c2-ca84-4f69-b648-8a014ff6e55d"}
'
curl -XGET "http://localhost:9200/myindex/_refresh"
echo "Searching..."
curl -XPOST "http://localhost:9200/myindex/_search?pretty=true" -d '{
"query": {
"term": {
"Id": "2c4294c2-ca84-4f69-b648-8a014ff6e55d"
}
}
}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment