Data modeling for restaurants
Firstly, we need to see the aspects of data and model it around a JSON document for Elasticsearch to make sense of the data. A restaurant has a name, its location information, and rating. To store the location information, Elasticsearch has a provision to understand the latitude and longitude information and has features to conduct searches based on it. Hence, it would be best to use this feature.
Let's see how we can do this.
First, let's see what our document should look like:
{ "name" : "Tamarind restaurant", "location" : { "lat" : 1.10, "lon" : 1.54 } }
Now, let's define the schema for the same:
curl -X PUT "http://$hostname:9200/restaurants" -d '{ "index": { "number_of_shards": 1, "number_of_replicas": 1 }, "analysis":{ "analyzer":{ "flat" : { "type" : "custom", "tokenizer" : "keyword", "filter" : "lowercase" } ...