Skip to content

Instantly share code, notes, and snippets.

@imotov
Created July 11, 2012 20:59
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 imotov/9d67c5c2b047a962dcf5 to your computer and use it in GitHub Desktop.
Save imotov/9d67c5c2b047a962dcf5 to your computer and use it in GitHub Desktop.
curl -XDELETE 'http://localhost:9200/collection' && echo
curl -XPUT 'http://localhost:9200/collection' && echo
curl -XPUT 'http://localhost:9200/collection/rec/_mapping' -d '{
"rec": {
"properties" : {
"calendar" : {
"dynamic" : "true",
"properties" : {
"startDate" : {"type":"date", "format":"MM/dd/YYYY" },
"endDate" : {"type":"date", "format":"MM/dd/YYYY" }
}
}
}
}
}' && echo
curl -XPUT 'http://localhost:9200/collection/rec/1' -d '{
"calendar" :{
"startDate" : "01/01/2012",
"endDate" : "01/31/2012"
}
}' && echo
curl -XPUT 'http://localhost:9200/collection/rec/2' -d '{
"calendar" :{
"startDate" : "02/01/2012",
"endDate" : "02/28/2012"
}
}' && echo
curl -XPUT 'http://localhost:9200/collection/rec/3' -d '{
"calendar" :{
"startDate" : "03/01/2012",
"endDate" : "03/15/2012"
}
}' && echo
curl -XPUT 'http://localhost:9200/collection/rec/4' -d '{
"calendar" :{
"startDate" : "03/16/2012",
"endDate" : "03/31/2012"
}
}' && echo
curl -XPOST 'http://localhost:9200/collection/_refresh'
curl -XPOST 'http://localhost:9200/collection/rec/_search?pretty=true' -d '{
"query": {
"bool": {
"must": [
{ "range": { "calendar.startDate": { "gte": "1/10/2012" } } },
{ "range": { "calendar.endDate": { "lte": "3/16/2012" } } }
]
}
}
}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment