Best way to model documents without needing of join

I have the following model in a traditional relational database:

  • Restaurant [id, name, address, phone, etc.]
  • RestaurantMenu [restaurant_id, menu_item_name, menu_item_price]

In Restaurant I store the information about a restaurant. I can have thousands of restaurants.

In RestaurantMenu I store all the itens in the menu of each restaurant.
Example:
[joe's pizza, cheese pizza, 10,00]
[joe's pizza, pepperoni pizza, 12,00]
[nakiru sushi, sashimi, 20,00]
[nakiru sushi, niguiri, 16,00]

When I'm searching for "What restaurants can I find cheese pizza?", I do "select name from restaurant, restaurantmenu where restaurantmenu.menu_item_name like '%cheese pizza%' and restaurant.id = restaurantmenu.restaurant_id".

How can I achieve same results with ElasticSearch? I was told I can't do joins in ES. What would be the best way to create my ES structure?

Have you tried denormalizing the data set, putting all the data for a dish and restaurant in each document?

Thanks. Once I found the nested datatype I understood the idea.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.