# Elastisearch daterange filter - days of week

**URL:** <https://discuss.elastic.co/t/elastisearch-daterange-filter-days-of-week/255750>\
**Category:** Elasticsearch\
**Created:** [November 17, 2020, 6:51pm UTC](https://discuss.elastic.co/t/elastisearch-daterange-filter-days-of-week/255750 "2020-11-17T18:51:28Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![shifra](https://avatars.discourse-cdn.com/v4/letter/s/ce73a5/32.png) [@shifra](https://discuss.elastic.co/u/shifra)\
**Post date:** [November 17, 2020, 6:51pm UTC](https://discuss.elastic.co/t/elastisearch-daterange-filter-days-of-week/255750/1 "2020-11-17T18:51:28Z")

</div>

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:

```auto
  {
      "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:

```auto
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

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

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [December 15, 2020, 6:51pm UTC](https://discuss.elastic.co/t/elastisearch-daterange-filter-days-of-week/255750/2 "2020-12-15T18:51:33Z")

</div>

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