1

I am trying to return current date data between set times. The query below is returning all data for today. The tricky bit that I am finding to do is to only return the data between midnight and 1pm for today.

How can I attempt this? FYI – the doctype ‘VT’ has value of 2017-10-13 04:35:02.33 Not sure if that might help

POST _search
{
    "query": {
        "range": {
            "VT": {
                "gte": "now/d" 
            }
        }
    }

}
Rich
  • 177
  • 2
  • 3
  • 13
  • I guess you are using python, so you can handle the gte and lte in your python code and just pass it to the query. – Hatim Stovewala Oct 13 '17 at 12:11
  • @hatim, i am using python. could you take a look at my other post - https://stackoverflow.com/questions/46712620/how-to-use-date-range-in-python-to-pull-query-data-using-current-date and see if you can help on that? – Rich Oct 13 '17 at 12:12

2 Answers2

0

Hope this will help you

POST _search
{
    "query": {
        "bool": {
            "must": [
            {
                "range": {
                    "VT": {
                        "gte": "now/d" 
                    }
                }
            },
            {
                "range": {
                    "VT": {
                        "gte": "00:00:00",
                        "lte": "13:00:00",
                        "format": "H:m:s"
                    }
                }
            }]
        }
    }
}
pravindot17
  • 1,199
  • 1
  • 15
  • 32
  • i got a error saying - duplicate key "range" - "type": "parsing_exception", "reason": "[range] malformed query, expected [END_OBJECT] but found [FIELD_NAME]", – Rich Oct 13 '17 at 12:08
  • still not work. i guess this is not doable. been stuck on it for days now – Rich Oct 13 '17 at 12:15
0

Can this help you?

POST _search
{
    "query": {
        "range": {
            "VT": {
                "gte": "now/d",
                "lt": "now/d+13h"
            }
        }
    }

}
dadoonet
  • 14,109
  • 3
  • 42
  • 49