If you define date facets like this.
"facets" : {
"expiry-date" : {
"range" : {
"field" : "expiry-date",
"ranges" : [ {
"to" : "2013-01-09T22:26:09.293+01:00"
}, {
"from" : "2013-01-09T22:26:09.293+01:00",
"to" : "2013-01-10T22:26:09.293+01:00"
}, {
"from" : "2013-02-09T22:26:09.293+01:00"
} ]
}
}
You will get results like this
"facets": {
"expiry-date": {
"_type": "range",
"ranges": [
{
"to": 1357766769293,
"to_str": "2013-01-09T22:26:09.293+01:00",
"count": 1252,
"min": 1357698130000,
"max": 1357698730000,
"total_count": 1252,
"total": 1699838444540000,
"mean": 1357698438130.9905,
},
{
"from": 1357766769293,
"from_str": "2013-01-09T22:26:09.293+01:00",
"to": 1357853169293,
"to_str": "2013-01-10T22:26:09.293+01:00",
"count": 0,
"total_count": 0,
"total": 0,
"mean": 0,
},
{
"from": 1360445169293,
"from_str": "2013-02-09T22:26:09.293+01:00",
"count": 0,
"total_count": 0,
"total": 0,
"mean": 0,
}
]
}
}
Then the java api will sometimes shuffle the results. Which makes it hard to know what range is what when you get the result, unless you compare the from and to dates or numbers.
If you introduce a pass through "label":"my-range" for each range, it would be easier to map the results to the datastructure (perhaos a GUI) that need the range numbers.
This would make the request and response look like this.
Request:
"facets" : {
"expiry-date" : {
"range" : {
"field" : "expiry-date",
"ranges" : [ {
"label" : "up-to-09th",
"to" : "2013-01-09T22:26:09.293+01:00"
}, {
"label" : "from-09th-to-10th",
"from" : "2013-01-09T22:26:09.293+01:00",
"to" : "2013-01-10T22:26:09.293+01:00"
}, {
"label" : "10th-and-beyond",
"from" : "2013-02-09T22:26:09.293+01:00"
} ]
}
}
Response:
"facets": {
"expiry-date": {
"_type": "range",
"ranges": [
{
"label" : "up-to-09th",
"to": 1357766769293,
"to_str": "2013-01-09T22:26:09.293+01:00",
"count": 1252,
"min": 1357698130000,
"max": 1357698730000,
"total_count": 1252,
"total": 1699838444540000,
"mean": 1357698438130.9905,
},
{
"label" : "from-09th-to-10th",
"from": 1357766769293,
"from_str": "2013-01-09T22:26:09.293+01:00",
"to": 1357853169293,
"to_str": "2013-01-10T22:26:09.293+01:00",
"count": 0,
"total_count": 0,
"total": 0,
"mean": 0,
},
{
"label" : "10th-and-beyond"
"from": 1360445169293,
"from_str": "2013-02-09T22:26:09.293+01:00",
"count": 0,
"total_count": 0,
"total": 0,
"mean": 0,
}
]
}
}
If you define date facets like this.
You will get results like this
Then the java api will sometimes shuffle the results. Which makes it hard to know what range is what when you get the result, unless you compare the from and to dates or numbers.
If you introduce a pass through
"label":"my-range"for each range, it would be easier to map the results to the datastructure (perhaos a GUI) that need the range numbers.This would make the request and response look like this.
Request:
Response: