“Searching and Sorting”, made simpler with ElasticSearch and RESTful APIs

Weiyuan
7 min readMay 2, 2021
source: pixabay, author: Free-Photos

“Searching” is a classic problem that many web applications face.

Look at any e-commerce site — to find what you want from their vast catalog of products, you can run a search on related keywords. Or social websites like Facebook and Reddit — search serves as an entry point to find relevant content like users, threads, and so on.

At times, implementing search on a backend application can be a simple process. If you are using a relational database that supports Structured Query Language (SQL), plugging in the LIKE operator in a query could work in finding relevant data.

However, what if you need to order the results by relevance to the search terms? The LIKE operator may not help us here, but there are other features like full-text searching that aims to solve this problem. Still, the problem remains if we continue to stretch the question to searching across database instances. The conventional database is not fully equipped to solve this application problem, but we can look elsewhere for a solution.

In comes Elasticsearch, can it solve our problem?

Elasticsearch is a distributed, free and open search and analytics engine for all types of data, including textual, numerical, geospatial, structured, and unstructured.

From elastic.co, “What is Elasticseach?”

Ironically, I came to know of Elasticsearch when I was instructed to use the ELK stack (Elasticsearch, Logstash, and Kibana) as the logging solution by my past employer. It’s a powerful solution, able to retrieve search results from both structured and unstructured data.

In Elasticsearch, there are two basic things to know about it in relation to its search capabilities — “indices” and “documents”.

--

--

Weiyuan

Senior Engineering Manager, Ascenda Loyalty | Former Engineering Manager, Grab | Former Director of Engineering, ZilLearn | bit.ly/weiyuan