Find a date range witch donc exist

Hi, I'm a new Elasticsearch user (v1.7). I have an index who look like this :

    // house with occuped planning
    {
           "id": "54",
           "city": "foo",
           "planning": [
              {
                 "id": 839,                     
                 "start": "2018-02-10T16:00:00+00:00",
                 "end": "2018-02-17T10:00:00+00:00"
              },
             {
                 "id": 833,                     
                 "start": "2018-02-22T16:00:00+00:00",
                 "end": "2018-02-29T10:00:00+00:00"
              }
           ]
    }

I want to find a way for get houses in city "foo" which have no occuped planning in a range between (or overlap) two dates.

POST /index/house/_search
{
   "query": {
     "bool": {
     "must": [
            {
               "term": {
                  "city": "foo"
               }
            }
         ]
      }
   }
}

I dont find what kind of query/nested/filter (?) have I to add :frowning:

I'm sure you would like to use a date range data type: https://www.elastic.co/guide/en/elasticsearch/reference/current/range.html

yes but it find planning with start date before and end date after but not in ONE planning so it is not correct
i want to check planning by planning if one correspond to te good ranges

Ah? I think that "relation": "within" would do it. Unless I'm misunderstanding what you wrote. In which case, I'd encourage you providing a full recreation script.

BTW I just noticed that you are using 1.7 which is not supported anymore and don't have date range type field. You'd better start with 5.6 as you are a new user.

(I have a technical constraint because the server I use have another instance of ES 1.7 ...)

Then I believe it's hard to solve your problem IMO.

May be others have ideas?

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