I am having data with date field value in "dd-mm-yyyy" format in my index. I try to find the unique of date with cardinality aggregation but i am getting wrong result.
POST /index/_search?size=-0
{
"aggs" : {
"type_count" : {
"cardinality" : {
"field" : "dateField"
}
}
}
}
My data has around 200 date unique dates but it is returning 3. Does cardinality aggregation works on date property?
jpountz
(Adrien Grand)
December 29, 2017, 8:36am
2
Can you share the output of the terms
aggregation on the same field?
Here is the output-
{
"took": 1031,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"skipped": 0,
"failed": 0
},
"hits": {
"total": 17622001,
"max_score": 0,
"hits": []
},
"aggregations": {
"type_count": {
"value": 3
}
}
}
jpountz
(Adrien Grand)
December 29, 2017, 12:11pm
4
I ran
GET /order/_search
{
"aggs" : {
"genres" : {
"terms" : { "field" : "creationDateOnlyStr" }
}
}
}
& it returns -
"aggregations": {
"genres": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": 1483229280000,
"key_as_string": "01-08-2017",
"doc_count": 6450000
},
{
"key": 1483228860000,
"key_as_string": "01-01-2017",
"doc_count": 5832001
},
{
"key": 1483229040000,
"key_as_string": "01-04-2017",
"doc_count": 5340000
}
]
}
}
Still not expected result
jpountz
(Adrien Grand)
December 29, 2017, 2:22pm
6
Thanks, I think I understand the problem: you used dd-mm-yyyy
instead of dd-MM-YYYY
. For y
it doesn't matter, but for m
it does since m
is minute of hour while M
is month of the year: http://www.joda.org/joda-time/apidocs/org/joda/time/format/DateTimeFormat.html .
system
(system)
Closed
January 27, 2018, 2:02pm
8
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.