Skip to content

Instantly share code, notes, and snippets.

@manuelbrunner
Created April 23, 2014 13:44
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 manuelbrunner/11215712 to your computer and use it in GitHub Desktop.
Save manuelbrunner/11215712 to your computer and use it in GitHub Desktop.
#!/bin/sh
curl -XPUT 'http://localhost:9200/test/offer/1' -d '{
"arrival": "2015-01-01",
"price": 100,
"hotel_id": "H1",
"offer_code": "O1"
}'
echo
curl -XPUT 'http://localhost:9200/test/offer/2' -d '{
"arrival" : "2015-01-01",
"price" : 90,
"hotel_id": "H1",
"offer_code": "O2"
}'
echo
curl -XPUT 'http://localhost:9200/test/offer/3' -d '{
"arrival" : "2015-01-02",
"price" : 80,
"hotel_id": "H1",
"offer_code": "O3"
}'
echo
curl -XPUT 'http://localhost:9200/test/offer/4' -d '{
"arrival": "2015-01-01",
"price": 100,
"hotel_id": "H2",
"offer_code": "O1"
}'
echo
sleep 1
curl -XPOST "http://localhost:9200/test/offer/_search?pretty=true" -d'
{
"size": 0,
"aggregations": {
"arrival": {
"filter": {
"term": {
"arrival": "2015-01-01"
}
},
"aggregations": {
"hotel_ids": {
"terms": {
"field": "hotel_id",
"order": {
"min_price": "asc"
}
},
"aggregations": {
"min_price": {
"min": {
"field": "price"
}
}
}
}
}
}
}
}'
echo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment