title: Filter Elasticsearch by day of week and time
body: <p>I have an index for businesses in Elasticsearch. Each document in the index represent a business, and each business has business_hours. I'm trying to allow a filter on the business hours using the day of the week and the time. For example,we'd like to be able to do a filter for <em>show we all business that are open Tuesday Evenings after 6:00PM</em>
  I'm thinking that we should have a field with the following mappings:</p>
  <pre><code>  {
        &quot;mappings&quot;: {
          &quot;properties&quot;: {
            
            &quot;business_hours&quot;: {
                               &quot;type&quot;: &quot;date_range&quot;,
                              &quot;format&quot;: &quot;w'T'hh:mma&quot;
            }
          }
        }
      }
  </code></pre>
  <p>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:</p>
  <pre><code>POST my-index/_doc
      {
        &quot;name&quot;: &quot;My Store&quot;,
        &quot;business_hours&quot;: [
          {
          &quot;gte&quot;: &quot;1T09:00AM&quot;,
          &quot;lte&quot;: &quot;1T05:00PM&quot;
          },
          {
          &quot;gte&quot;: &quot;2T09:30AM&quot;,
          &quot;lte&quot;: &quot;2T05:00PM&quot;
          }
        ]
      }
  </code></pre>
  <p>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?</p>
  <p>Here's the query I used. Its supposed to filter for business open on Wednesday but it returned the document above which only had business hours on Monday and Tuesday</p>
  <pre><code>GET my-index/_search
  {
    &quot;query&quot;: {
      &quot;bool&quot;: {
        &quot;filter&quot;: [
          {
            &quot;range&quot;: {
              &quot;business_hours&quot;: {
                &quot;gte&quot;: &quot;3T10:00AM&quot;,
                &quot;lte&quot;: &quot;3T05:00PM&quot;,
                &quot;relation&quot;: &quot;CONTAINS&quot;
              }
            }
          }
        ]
      }
    }
  }
  </code></pre>