Availability of employees during a period

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 !

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

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

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 ?

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

1 Like