Trying to do a simple query filter

Good Day,

Maybe Im just over thinking this, but I just want to do a simple filter / query on a numberic number.

I have a document with a timestamp and hour (0-23) have the query of data I need, but I need to filter / query it where docHour is greater than 23 (11:00pm) and less than 04 (4:00am) but Its just not working. What is the best way to do this kind of query. Do I use multiple ranges ???

this works for me

{
  "query": {
    "bool": {
      "must": [
        {
          "range":{"timestamp" : {"gte": "2019-02-26 23:00:00", "lte": "2019-02-27 04:00:00"}}
        }
      ]
    }
  }
}

The problem with that query is that I only want where time is greater than 11:00pm and less that 4:00am. I only need those hours per day. So I can't use the date part cause it will then use the date as well.

I do have a field for hour which is an integer that is from 0 - 23. Thats why I want to use hour .

Could you provide a full recreation script as described in About the Elasticsearch category. It will help to better understand what you are doing. Please, try to keep the example as simple as possible.

A full reproduction script will help readers to understand, reproduce and if needed fix your problem. It will also most likely help to get a faster answer.

GET tmc2018_feb/_search

{
"query":
{
"bool": {
"should": [
{"match": { "dayOfWeek.keyword": "Tue"}},
{"match": { "dayOfWeek.keyword": "Wed"}},
{"match": { "dayOfWeek.keyword": "Thu"}}
]
}
},
"sort": [
{
"measurement_timestamp": {
"order": "asc"
}
}
]
}

Forgive me for my newbie status with this.

Basically what I'm trying to do it...
1.) return records to me that are from Tue, Wed, or Thu. Now I also only want records that are from the hours of 11:00pm to 4:00am in the morning. I also have a DateTime field named ' measurement_timestamp ' if that is better to use, but to seperate and filter against the times and day it was suggested I have those fields seperate (thus the hours and DayOfWeek fields).
2.) sort asc

I can't copy and paste to reproduce anything.
Please follow my instructions if you need further assistance.

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