Ludovic Frank - Freelance developer

No, MYSQL and MariaDB are not search engines...

ionicons-v5-k Ludovic Frank Nov 8, 2021
118 reads Level: intermediate

Hey there.
How are you? Good, not too cold? so much the better!
This week's article is for my fellow developers, and we're going to talk about search ... but real search!

I often see MYSQL used as a search engine ...

It's a fact! In the projects I've worked on, I've often seen this database management system (or MariaDB or Postgresql) used as a search engine, with things like "where my_attribute LIKES '%blabla%".
And this is a very bad practice...

What's the real use of a relational database system?

In my opinion, a relational database management system is designed for a simple task, i.e. ... storing data and accessing it directly. Let me explain: if you tell MYSQL that you want to access one or more entries, clearly specifying its id or one of its other attributes, then it will be able to find what you want very quickly.it's designed for that, but if you start using it as a search engine ... it won't perform well ... just the code needed to search on several fields is a joke ... like "where my_attribute 1 LIKES or where ...."Anyway, you get the idea (at worst, test it yourself?).

Indexed databases

In fact, for search purposes, there are other database systems, called indexed databases, of which there are several (like DBMS).

Unlike DBMSs, there are no relationships; the data is "just laid out" flat in an indexed database.for articles, for example, each line contains its category in full, unlike in a DBMS, where you'd put a simple link pointing to the category - you're there to search! not to optimize memory space ... ?

A SAAS solution: Algolia

What's SAAS? I wrote an article about it, didn't I?
Just off the top of my head, as a SAAS solution, there's Algolia, which I used a few years ago on a dev project for this site, and which they're still using today. At the time, I chose Algolia because the performance/cost ratio was interesting, but today they've changed their business model and I think it's less interesting, but that's just my opinion.

For those who want to go further with indexed databases...

For those who want to get their hands dirty in Open Source, there's ElasticSearch or Lucene, for example.
These are the best-known indexed databases, and are very well documented.
If you want an example of search with ElasticSearch, you can find one on this page of my site. At the time (a year ago), I used ELS to have a quick little search engine, and it did the job perfectly and was the basis of my own system... Ludo Dev - Lightning Search.

Deliver a satisfying search experience.

Here you'll see what's possible when based on the right tools ....

For my latest projects, I wanted an ultra-fast, ultra-efficient search engine.

So, based on ElasticSearch, I made my own ultra-optimized version. I wanted it to be simple, fast and efficient, and I wanted :

  • A quick little search bar, I start typing and it's already guessed ... which makes for a very pleasant user experience.
  • The search bar needed to be typo-tolerant, because people on the Internet want to move fast! so they make typos (and with the phone keyboard, I'm not even talking about that).irrattrapable, but forgetting accents or writing "mont d'ar" instead of "mont d'or" is catchable.
  • An advanced mode with "facets", I tick off what interests me and that allows me to cross, for example here, a raw goat's milk cheese, that's possible.

So you can see the result of the little search bar on the online cheese shop, and in the list of cheeses it's the more advanced search engine... I've tried to make it fast, user-friendly and very pleasant to use, as I've said before.s pleasant to use, as I said, Lightning Search is based on ElasticSearch with in-house patches to make it even faster... even with lots of searches at the same time.

Conclusion

The idea of this article was to point you in the direction of good practices in terms of search, but I didn't want it to fall right into your lap, either. You'll have to do a bit of research to make a nice search engine... but you're passionate... so you'll get there?
See you next week?