Created
April 5, 2011 13:47
-
-
Save lukas-vlcek/903622 to your computer and use it in GitHub Desktop.
Histogram count issue
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
curl -XDELETE http://localhost:9200/indexname | |
curl -XPUT http://localhost:9200/indexname | |
echo | |
curl -XPUT 'http://localhost:9200/indexname/histogram/_mapping?pretty=1' -d ' | |
{ | |
"histogram": | |
{ | |
"properties": | |
{ | |
"date1" : { "type" : "date" }, | |
"date2" : { "type" : "date" } | |
} | |
} | |
} | |
'; | |
echo | |
for (( i = 1; i < 21; ++i )) | |
do | |
curl -XPUT "http://localhost:9200/indexname/histogram/$i" -d " | |
{ | |
\"date1\" : \"$(date +%Y-%m)-$i\", | |
\"date2\" : \"2009-11-11T16:34:34.000Z\" | |
}"; | |
done | |
curl -XPOST http://localhost:9200/_refresh | |
curl -XGET 'http://localhost:9200/indexname/_search?search_type=count&pretty=1' -d ' | |
{ | |
"query" : { "match_all" : {} }, | |
"facets" : { | |
"histogram1" : { | |
"date_histogram" : { "field" : "date1", "interval" : "1d" } | |
}, | |
"histogram2" : { | |
"date_histogram" : { "field" : "date2", "interval" : "1d" } | |
} | |
} | |
}' | |
echo | |
// ############################# | |
// outputs the following, note the count of 24 in facets! | |
// ############################# | |
{ | |
"took" : 2, | |
"timed_out" : false, | |
"_shards" : { | |
"total" : 3, | |
"successful" : 3, | |
"failed" : 0 | |
}, | |
"hits" : { | |
"total" : 20, | |
"max_score" : 0.0, | |
"hits" : [ ] | |
}, | |
"facets" : { | |
"histogram1" : { | |
"_type" : "histogram", | |
"entries" : [ { | |
"time" : 1301702400000, | |
"count" : 4 | |
}, { | |
"time" : 1301961600000, | |
"count" : 4 | |
}, { | |
"time" : 1302220800000, | |
"count" : 4 | |
}, { | |
"time" : 1302566400000, | |
"count" : 4 | |
}, { | |
"time" : 1302825600000, | |
"count" : 4 | |
}, { | |
"time" : 1303084800000, | |
"count" : 4 | |
} ] | |
}, | |
"histogram2" : { | |
"_type" : "histogram", | |
"entries" : [ { | |
"time" : 1257897600000, | |
"count" : 24 | |
} ] | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment