Skip to content

Instantly share code, notes, and snippets.

@imotov
Created March 27, 2013 00:34
Show Gist options
  • Save imotov/5250599 to your computer and use it in GitHub Desktop.
Save imotov/5250599 to your computer and use it in GitHub Desktop.
curl -XDELETE "localhost:9200/test"
curl -XPUT "localhost:9200/test" -d '{
"mappings": {
"doc": {
"properties": {
"price": {
"type": "long"
},
"colour": {
"type": "string",
"index": "not_analyzed"
},
"feature": {
"type": "string",
"index": "not_analyzed"
}
}
}
}
}'
curl -XPUT "localhost:9200/test/doc/1" -d '{"price": 10, "colour" : "Red", "feature" : ["Square", "Shiny", "Solid"]}'
curl -XPUT "localhost:9200/test/doc/2" -d '{"price": 30, "colour" : "Red", "feature" : ["Square", "Shiny", "Squishy"]}'
curl -XPOST "localhost:9200/test/_refresh"
echo
curl "localhost:9200/test/doc/_search?pretty=true" -d '{
query : {
"filtered" : {
"query" : {
"match_all" : {}
},
"filter" : {
"and" : [
{
"term" : {
"colour" : "Red"
}
},
{
"term" : {
"feature" : "Square"
}
},
{
"term" : {
"feature" : "Shiny"
}
}
]
}
}
},
"facets" : {
"colours" : {
"terms" : {
"field" : "colour"
},
"facet_filter" : {
"range" : { "price" : { "from" : "10", "to" : "20" } }
}
},
"features" : {
"terms" : {
"field" : "feature"
},
"facet_filter" : {
"range" : { "price" : { "from" : "10", "to" : "20" } }
}
},
"prices" : {
"statistical" : {
"field" : "price"
}
}
},
"filter": {
"range" : { "price" : { "from" : "10", "to" : "20" } }
}
}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment