Why a LIKE query is not search

Elasticsearch Course · lesson 1 of 19 · 4 min read

A relational scan and a search engine answer two genuinely different questions.

Open this lesson in the learning hub

Key points

  • LIKE '%boot%' starts with a wildcard, so no B-tree index applies and every row is read.
  • It matches raw substrings, so a search for cat also hits concatenate and catalogue.
  • A WHERE clause is a yes or no test: every matching row is equally good, in whatever order arrives.
  • Elasticsearch analyses text into terms first, so Running can be made to match run.
  • It then ranks what matched, so the ten best documents come back first rather than the ten oldest.
  • Search is recall plus ranking; if you only need an exact filter, a database is still the better tool.

A database filters rows; a search engine analyses text and ranks the results.

This is a reading copy. The full lesson — with the visual explainer, the interactive lab and a Run button for the code — lives in the Elasticsearch Course course, and every lesson in it is listed on the Elasticsearch Course contents page.