Skip to content

Instantly share code, notes, and snippets.

@jprante
Created October 29, 2014 23:35
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 jprante/5153404c8f09dc06163f to your computer and use it in GitHub Desktop.
Save jprante/5153404c8f09dc06163f to your computer and use it in GitHub Desktop.
Color search
curl -XDELETE 'localhost:9200/test'
curl -XPUT 'localhost:9200/test' -d '
{
"mappings" : {
"colors" : {
"properties" : {
"color" : {
"type": "string",
"analyzer" : "keyword"
}
}
}
}
}
'
curl -XPUT 'localhost:9200/test/colors/1' -d '
{
"color" : "red"
}
'
curl -XPUT 'localhost:9200/test/colors/2' -d '
{
"color" : "light red"
}
'
curl -XPUT 'localhost:9200/test/colors/3' -d '
{
"color" : "dark red"
}
'
curl -XPUT 'localhost:9200/test/colors/4' -d '
{
"color" : "metallic red"
}
'
curl -XGET 'localhost:9200/test/_refresh'
curl -XGET 'localhost:9200/test/colors/_search?pretty' -d '
{
"query": {
"term": {
"color" : "red"
}
}
}
'
# -> 1 hit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment