Hi Guys,
I have three document
{
"plant": "F130",
"partno": "aa.123.abcds",
"date": "20150903",
"curr": "NTD",
"cost": "1000",
}
{
"plant": "F130",
"partno": "aa.123.abcds",
"date": "20151203",
"curr": "NTD",
"cost": "1200",
}
{
"plant": "F130",
"partno": "aa.123.abcds",
"date": "20151215",
"curr": "NTD",
"cost": "1500",
}
and now I need to get document with max date value. so I use this query to get result
{
"query": {
"bool": {
"must": [
{
"term": {
"plant": "f130"
}
},
{
"term": {
"partno": "aa.123.abcds"
}
},
{
"term": {
"curr": "ntd"
}
}
]
}
},
"aggregations": {
"by_date": {
"max": {
"field": "date"
}
}
}
}
But aggregation the result is
"aggregations": {
"by_date": {
"value": 1450137600000,
"value_as_string": "20151215"
}
what I expected is this document
{
"plant": "F130",
"partno": "aa.123.abcds",
"date": "20151215",
"curr": "NTD",
"cost": "1500",
}
Can anyone help me how to do it?
Thanks