In today’s post, I want to introduce you a concept called Entity-component System and to show how to use it for web development.
The idea is not new. In fact, it is widely used in game development. But I have never heard about it when talking about backend development and data modeling.

If you build a web-service around content, then it is a matter of time when you need to introduce a search functionality.

Depending on the shape of your data you may go the easiest way: search using a regular expression against some field (title, name, etc.). But what if you have more than one field? What if the data is spread across several collections? You would probably also want to have a ‘search rank,’ i.e. to know how close the match is.

This way the simple solution will not work anymore. Or it won’t be simple.