Range query on nested object - get latest entry

Hi,
I have the following document:

{
	"attributes":[
		{
			"name": "a"
			"effectiveDate": "01-01-2016"
		},{
			"name": "b"
			"effectiveDate": "01-01-2017"
		},{
			"name": "c"
			"effectiveDate": "01-01-2018"
		},{
			"name": "d"
			"effectiveDate": "26-02-2017"
		}
	]
}

With the following mappings:

"attributes": {
      "type": "nested",
      "properties": {
        "name": {
          "type": "keyword"
        },
        "effectiveDate": {
          "type": "date"
        }
      }
}

Is there a way to create a nested range query, so I can get back the closest entry to today.
let's say today is 28.2.2017, I want to get back:

{
    "name": "d"
    "effectiveDate": "26-02-2017"
}

Kind of select date< now() order by date limit 1;

Is this possible?

anyone?:expressionless:

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.