Skip to content

Instantly share code, notes, and snippets.

@allancaffee
Created December 22, 2011 15:18
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 allancaffee/1510658 to your computer and use it in GitHub Desktop.
Save allancaffee/1510658 to your computer and use it in GitHub Desktop.
Strange date histogram facet behavior with ElasticSearch version 0.18.5
curl -X PUT 'http://localhost:9200/articles/article/1?pretty=true' -d '{
"title": "One",
"some_date": "2000-01-01T00:00:00"
}'
# {
# "ok" : true,
# "_index" : "articles",
# "_type" : "article",
# "_id" : "1",
# "_version" : 1
# }
curl -X PUT 'http://localhost:9200/articles/article/2?pretty=true' -d '{
"title": "Two",
"some_date": "2000-01-01T00:01:00"
}'
# {
# "ok" : true,
# "_index" : "articles",
# "_type" : "article",
# "_id" : "2",
# "_version" : 1
# }
curl -X PUT 'http://localhost:9200/articles/article/3?pretty=true' -d '{
"title": "Three",
"some_date": "2000-01-01T00:02:00"
}'
# {
# "ok" : true,
# "_index" : "articles",
# "_type" : "article",
# "_id" : "3",
# "_version" : 1
# }
curl 'http://localhost:9200/articles/article/_search?pretty=true' -d '{
"query": {
"match_all": {}
},
"facets": {
"rollup": {
"date_histogram": {
"field": "some_date",
"interval": "minute",
"time_zone": "America/New_York"
}
}
}
}'
# {
# "took" : 4,
# "timed_out" : false,
# "_shards" : {
# "total" : 6,
# "successful" : 6,
# "failed" : 0
# },
# "hits" : {
# "total" : 3,
# "max_score" : 1.0,
# "hits" : [ {
# "_index" : "articles",
# "_type" : "article",
# "_id" : "3",
# "_score" : 1.0, "_source" : {
# "title": "Three",
# "some_date": "2000-01-01T00:02:00"
# }
# }, {
# "_index" : "articles",
# "_type" : "article",
# "_id" : "1",
# "_score" : 1.0, "_source" : {
# "title": "One",
# "some_date": "2000-01-01T00:00:00"
# }
# }, {
# "_index" : "articles",
# "_type" : "article",
# "_id" : "2",
# "_score" : 1.0, "_source" : {
# "title": "Two",
# "some_date": "2000-01-01T00:01:00"
# }
# } ]
# },
# "facets" : {
# "rollup" : {
# "_type" : "date_histogram",
# "entries" : [ {
# "time" : 946684800000,
# "count" : 1
# }, {
# "time" : 946684860000,
# "count" : 1
# }, {
# "time" : 946684920000,
# "count" : 1
# } ]
# }
# }
# }
curl 'http://localhost:9200/articles/article/_search?pretty=true' -d '{
"query": {
"match_all": {}
},
"facets": {
"rollup": {
"date_histogram": {
"field": "some_date",
"interval": "minute"
}
}
}
}'
# {
# "took" : 2,
# "timed_out" : false,
# "_shards" : {
# "total" : 6,
# "successful" : 6,
# "failed" : 0
# },
# "hits" : {
# "total" : 3,
# "max_score" : 1.0,
# "hits" : [ {
# "_index" : "articles",
# "_type" : "article",
# "_id" : "3",
# "_score" : 1.0, "_source" : {
# "title": "Three",
# "some_date": "2000-01-01T00:02:00"
# }
# }, {
# "_index" : "articles",
# "_type" : "article",
# "_id" : "1",
# "_score" : 1.0, "_source" : {
# "title": "One",
# "some_date": "2000-01-01T00:00:00"
# }
# }, {
# "_index" : "articles",
# "_type" : "article",
# "_id" : "2",
# "_score" : 1.0, "_source" : {
# "title": "Two",
# "some_date": "2000-01-01T00:01:00"
# }
# } ]
# },
# "facets" : {
# "rollup" : {
# "_type" : "date_histogram",
# "entries" : [ {
# "time" : 946684800000,
# "count" : 1
# }, {
# "time" : 946684860000,
# "count" : 1
# }, {
# "time" : 946684920000,
# "count" : 1
# } ]
# }
# }
# }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment