Searching Related Documents With Elasticsearch
In my last article we learned how to get started with Elasticsearch. In this article we are going to learn some strategies for dealing with related documents.
Relationships
Relationships between documents depend on the type of data we are storing. Some examples of relationships:
- Restaurants and locations, where a restaurant can have multiple locations, but a location can only belong to one restaurant. This is a one to many relationship.
- Orders and users, where each order belongs to a user. A user can have multiple orders but an order belongs to a single user. Also, one to many.
- Movies and actors. A movie can star multiple actors and an actor can star in multiple movies. Many to many relationship.