# Availability of employees during a period

**URL:** https://discuss.elastic.co/t/availability-of-employees-during-a-period/24075
**Category:** Elasticsearch
**Created:** [June 22, 2015, 11:19am UTC](https://discuss.elastic.co/t/availability-of-employees-during-a-period/24075 "2015-06-22T11:19:20Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![alexdtx](https://avatars.discourse-cdn.com/v4/letter/a/85e7bf/32.png) [@alexdtx](https://discuss.elastic.co/u/alexdtx)
#### Post date: [June 22, 2015, 11:19am UTC](https://discuss.elastic.co/t/availability-of-employees-during-a-period/24075/1 "2015-06-22T11:19:20Z")

</div>

Hello everybody,

I'm new on elasticsearch and in programming . My purpose is to use the search engine in order to search my employees according to their skills and their availabilities.

For the skills everything is good. For availability, I have no idea how could I do ? How could I map the document and how could I make a research.

Until now for each employee, I have a calendar with days of availability and days of unavailability.

Is it possible to do a research with a day of beginning and a day of end and display the number of day of availability ? or even diplay the date of each day of availability or unavailability ?

Does someone have any idea ? or a new way of thinking to resolve this problem ?

Thanks !

---

<div class="post-metadata">

### Author: ![eperry](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eperry/32/551_2.png) [@eperry](https://discuss.elastic.co/u/eperry)
#### Post date: [June 22, 2015, 12:47pm UTC](https://discuss.elastic.co/t/availability-of-employees-during-a-period/24075/2 "2015-06-22T12:47:42Z")

</div>

Try using RANGE  
[https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-range-query.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-range-query.html)

```auto
{
    "range" : {
        "born" : {
            "gte": "2012-01-01",
            "lte": "now",
            "time_zone": "+1:00"
        }
    }
}

```

---

<div class="post-metadata">

### Author: ![alexdtx](https://avatars.discourse-cdn.com/v4/letter/a/85e7bf/32.png) [@alexdtx](https://discuss.elastic.co/u/alexdtx)
#### Post date: [June 22, 2015, 1:13pm UTC](https://discuss.elastic.co/t/availability-of-employees-during-a-period/24075/3 "2015-06-22T13:13:46Z")

</div>

Ok so in this case, What should be the structure of my employee's document ?

Each employee can have 5 periods of availability and 4 periods of unavailability in one month by example. How can I model that ?

---

<div class="post-metadata">

### Author: ![salat](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/salat/32/690_2.png) [@salat](https://discuss.elastic.co/u/salat)
#### Post date: [June 22, 2015, 1:58pm UTC](https://discuss.elastic.co/t/availability-of-employees-during-a-period/24075/4 "2015-06-22T13:58:19Z")

</div>

You build a separate index "employee\_schedule" where you save the available dates of each employee. Afterwards you can filter by range and employee\_id, i.e.:

Index: employee  
Fields: Id, Firstname, Lastname

Index: employee\_schedule  
Fields: Id, Employee\_Id (link to employee index / maybe as parent field), available\_date\_start, available\_date\_end

So each employee can have multiple employee schedule entries... in your application logic you have to check for overlapping date ranges and prevent them.

Best  
Steph

---

<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: [July 6, 2017, 12:06am UTC](https://discuss.elastic.co/t/availability-of-employees-during-a-period/24075/5 "2017-07-06T00:06:09Z")

</div>


