Q:

Elastic search query scenario

I am building an application which requires a location based search of hotels.
I have three Main classes
class Hotel {
   String name
   String latitude
   String longitude
}

class HotelResource {
   Hotel hotel
   String name

}

class HotelResourceAvailability{
  HotelResource resource

}

HotelResourceAvailability - holds the availability data of a hotel resource.
The query scenario,
As a user I want to search for all the hotels in a particular location which have at least one hotel resource available
and get the count of available resources for each of the hotels
Note - The hotels matching the location criteria but without any available resource should be filtered out.
I am new to elastic search and finding it difficult to decide on the approach any pointers would be really appreciated.

A:

Three points to get you started:

I would keep your data model as flat as possible - Elasticsearch isn't relational so you can't easily join from one object to another.
Latitude and Longitude can be stored in the geo_point type - you can then use queries to find the nearest matching hotels.
Is Hotel availability based on date? if so I would use nesting or a parent child relationship.

