Availability of employees during a period


#1

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 !


(Ed) #2

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"
        }
    }
}

#3

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 ?


#4

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


(system) #5