Elastisearch daterange filter - days of week

Hi!
This is my first time on this forum, I hope my question is clear. Please let me know if I should add any details.

My goal: Implement a filter on days of week and time

I'm trying to implement a filter for open hours on my data. Each document in the index represent a business, and each business has business_hours.
We'd like to be able to do a filter for show we all business that are open Tuesday Evening
I'm thinking that we should have a field with the following mappings:

  {
      "mappings": {
        "properties": {
          
          "business_hours": {
                             "type": "date_range",
                            "format": "w'T'hh:mma"
          }
        }
      }
    }

Each document would then have an array of business_hours.
So a store that is open on Monday 9:00AM - 5:00PM, and Tuesday 9:30AM - 5:00PM would look like this:

POST my-index/_doc
    {
      "name": "My Store",
      "business_hours": [
        {
        "gte": "1T09:00AM",
        "lte": "1T05:00PM"
        },
        {
        "gte": "2T09:30AM",
        "lte": "2T05:00PM"
        }
      ]
    }

I tried to search this document and query for it, but the filter for the hours is not working, they look like theyre getting ignored....
Does Elasticsearch support filtering by a day of the week or does it need to be an actual datetime?

The Search Query I used was to filter if a business is open on Wednesday returned the above business which is not open on Wednesday

GET my-index/_search
{
  "query": {
    "bool": {
      "filter": [
        {
          "range": {
            "business_hours": {
              "gte": "3T10:00AM",
              "lte": "3T05:00PM",
              "relation": "CONTAINS"
            }
          }
        }
      ]
    }
  }
}

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