Skip to content

Instantly share code, notes, and snippets.

/curl_queries.sh Secret

Created May 23, 2012 08: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 anonymous/d3234db747e6e845d1e5 to your computer and use it in GitHub Desktop.
Save anonymous/d3234db747e6e845d1e5 to your computer and use it in GitHub Desktop.
Facet filters using nested objects
curl -XPUT 'http://localhost:9200/test'
curl -XPUT 'http://localhost:9200/test/type1/_mapping' -d '{"type1":{"properties":{"testobj":{"properties":{"idtest":{"type":"long","include_in_all":false},"obj1":{"type":"nested","dynamic":"true","properties":{"date":{"type":"date","format":"dateOptionalTime","include_in_all":false},"id":{"type":"long","include_in_all":false}}}}}}}}'
curl -XPOST 'http://localhost:9200/test/type1/1' -d '{"testobj":{"idtest":1,"obj1":[{"date":"2012-01-01T00:02:00Z","id":4},{"date":"2012-01-01T02:11:00Z","id":6}]}}'
curl -XPOST 'http://localhost:9200/test/type1/_search?pretty=true' -d '{"facets":{"facet1":{"date_histogram":{"field":"date","interval":"hour"},"nested":"testobj.obj1","facet_filter":{"and":[{"range":{"testobj.obj1.date":{"from":"2012-01-01T00:00:00Z","to":"2012-02-01T00:00:00Z"}}}]}}}}'
curl -XPOST 'http://localhost:9200/test/type1/_search?pretty=true' -d '{"facets":{"facet1":{"date_histogram":{"field":"date","interval":"hour"},"nested":"testobj.obj1","facet_filter":{"and":[{"exists":{"field":"testobj.idtest"}},{"range":{"testobj.obj1.date":{"from":"2012-01-01T00:00:00Z","to":"2012-02-01T00:00:00Z"}}}]}}}}'
{
"testobj":{
"idtest":1,
"obj1":[
{
"date":"2012-01-01T00:02:00Z",
"id":4
},
{
"date":"2012-01-01T02:11:00Z",
"id":6
}
]
}
}
{
"type1":{
"properties":{
"testobj":{
"properties":{
"idtest":{
"type":"long",
"include_in_all":false
},
"obj1":{
"type":"nested",
"dynamic":"true",
"properties":{
"date":{
"type":"date",
"format":"dateOptionalTime",
"include_in_all":false
},
"id":{
"type":"long",
"include_in_all":false
}
}
}
}
}
}
}
}
{
"facets":{
"facet1":{
"date_histogram":{
"field":"date",
"interval":"hour"
},
"nested":"testobj.obj1",
"facet_filter":{
"and":[
{
"exists":{
"field":"testobj.idtest"
}
},
{
"range":{
"testobj.obj1.date":{
"from":"2012-01-01T00:00:00Z",
"to":"2012-02-01T00:00:00Z"
}
}
}
]
}
}
}
}
{
"facets":{
"facet1":{
"date_histogram":{
"field":"date",
"interval":"hour"
},
"nested":"testobj.obj1",
"facet_filter":{
"and":[
{
"range":{
"testobj.obj1.date":{
"from":"2012-01-01T00:00:00Z",
"to":"2012-02-01T00:00:00Z"
}
}
}
]
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment