Elasticsearch – Simple Introduction and Web App

Searching through 399 documents or 40 web pages (the numbers are not random) can be a tough task if you rely on standard tools like ctrl+f. When the data grows, you need a dedicated search engine that understands relevance, handles typos, and delivers results instantly.

In this article, we will only build a simple search engine with Python and the power of Elasticsearch. Elasticsearch is now an industry-standard, distributed search and analytics engine designed for horizontal scalability and real-time search.

The YouTube (below) actually presents the code from 3 parts:

  1. We write a crawler to go around vitoshacademy.com and index the first 40 pages in real time. (Long time ago, I have built something similar)
  2. Then we build a local indexer to process 399 static text files directly from the harddrive, simulating some document archive.
  3. The last part of the video is actually a bit better – we step away from the terminal and wrap everything in a web app with Flask. Simple one, with just a field, a button and divs to display results.

This is what the Flask app with elastic search looks like.

The code of the text searcher is here – the indexer:

And the search itself:

The Docker command is that one:

The rest is in GitHub!

šŸ™‚

Tagged with: , , , , ,