Created
December 16, 2010 18:12
-
-
Save rkroll/743752 to your computer and use it in GitHub Desktop.
Displays the histogram oddness on dates
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// delete the index | |
curl -XDELETE 'http://localhost:9200/test/' | |
// create index | |
curl -XPUT 'http://localhost:9200/test/' -d ' | |
{ | |
index : { | |
number_of_shards : 5, | |
number_of_replicas : 0 | |
} | |
} | |
' | |
// put event mapping | |
curl -XPUT 'http://localhost:9200/test/event/_mapping' -d ' | |
{ | |
"event" : { | |
"properties" : { | |
"date_reported" : {"type" : "date"}, | |
"message" : {"type" : "string", "store" : "yes"} | |
} | |
} | |
} | |
' | |
// index documents to ES | |
curl -XPOST 'http://localhost:9200/test/event/' -d ' | |
{ | |
"date_reported" : "2010-12-13T17:21:09+00:00", | |
"message" : "This is a test" | |
} | |
' | |
curl -XPOST 'http://localhost:9200/test/event/' -d ' | |
{ | |
"date_reported" : "2010-12-16T17:21:09+00:00", | |
"message" : "This is a test" | |
} | |
' | |
// get all - both docs are present w/ the proper date/time & tz | |
curl -XGET 'http://localhost:9200/test/event/_search?pretty=true' -d ' | |
{ | |
"query" : { | |
"match_all" : { } | |
} | |
} | |
' | |
// get histo | |
curl -XGET 'http://localhost:9200/test/event/_search?pretty=true' -d ' | |
{ | |
"query" : { | |
"match_all" : {} | |
}, | |
"facets" : { | |
"histo1" : { | |
"histogram" : { | |
"field" : "date_reported", | |
"time_interval" : "12h" | |
} | |
} | |
} | |
} | |
' | |
// 1292241600000 = Mon Dec 13 07:00:00 EST 2010 & 1292500800000 = Thu Dec 16 07:00:00 EST 2010 as expected | |
curl -XGET 'http://localhost:9200/test/event/_search?pretty=true' -d ' | |
{ | |
"query" : { | |
"match_all" : {} | |
}, | |
"facets" : { | |
"histo1" : { | |
"histogram" : { | |
"field" : "date_reported", | |
"time_interval" : "24h" | |
} | |
} | |
} | |
} | |
' | |
//1292198400000 = Sun Dec 12 19:00:00 EST 2010 & 1292457600000 = Wed Dec 15 19:00:00 EST 2010 | |
// When expecting a histo on a full day - why does it shift the days? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment