Elasticsearch how to build search system

E

Current article is devoted to the problem of building advanced search system using ElasticSearch. We are going to create a real example of a simplified booking.com version but with some super additional features. Imagine that you are a software engineer and your boss gave you a task to build the whole backend. After analyzing all design mockups and functional requirements you have created some general simplified structure scheme of future hotels search system. Here how it looks like:

In short summary current system should perform full text search at hotel name and city name at different language variations, it also performs typical exact match at stars, rating, age. There is also some geo distance filter and possibility to search by facilities. In addition every hotel has comments and bookings whose data are also searchable. Hotel search system should satisfy all mentioned search variations. It also should to be super fast. But that is not the all problems we have. There are also extra requirements. Let’s investigate it one by one. First of all system should allow to provide hotels’s search within any custom shape provided by user. Here is the example of user interface:

At second we have to display the number of hotels on map as it is presented at image below:

And at third, for every hotel we need to provide the bar chart of avg rating from all comments per month within a year at every document. So we need additional data to display something like that:

where X would be months of the year and Y – number of comments.

While being responsible for building backend for such a system you may say; holy moly, how should I project such a system, how to meet all that requirements? It is always hard to check the right tool, especially nowadays when we have such a great variety of technologies in the IT area. But if I had to create such a system – I had no doubts at all. First of all we have to provide full text search operations, at second we need to perform some complicated geo operations. Additionally we have some analytics here. And all that should work at once and with a high speed. I know the only one tool that perfectly suits all those requirements.

And that is ElasticSearch. I will show that we can easily get all those things at several queries only. And I doubt that any similar system built using relational databases (e.g mysql, postgres or oracle) would be able to create a good competition for Elastic in that case. Either you will finish with overcomplicated architecture or it would be simply slow. Ok, that is the end of the current article. You may get acquainted with requirements at current video also, which is the first one at my udemy course devoted to ElasticSearch -> section “Advanced search system”. You may view the whole course at udemy using next link with discount: link to udemy




Related articles you can be interested on:

About the author

sergii-demianchuk

Software engineer with over 15 year’s experience. Everyday stack: PHP, Python, Java, Javascript, Symfony, Flask, Spring, Vue, Docker, AWS Cloud, Machine Learning, Ansible, Terraform, Jenkins, MariaDB, MySQL, Mongo, Redis, ElasticSeach

architecture cluster docker elasticsearch flask geo high availability java php programming languages python recommendation systems search systems spring boot symfony