@sargonpiraev

Search database

Created 1 min readseed · 1/5#database

A search database is optimized for finding documents by text, filters, and relevance.

The core idea is an inverted index. Instead of scanning every document, the database keeps a structure that maps terms to the documents that contain them.

Example

For documents:

1: "database indexes and query planning"
2: "search relevance and ranking"

An inverted index can map:

database -> [1]
query -> [1]
search -> [2]
ranking -> [2]

What it is good for

Search databases are useful for:

  • full-text search,
  • autocomplete,
  • filtering,
  • faceted navigation,
  • relevance ranking,
  • log search.

Tradeoff

Search databases are excellent at retrieval and ranking, but they are usually not the source of truth for transactional data. They often sit next to a relational database and receive indexed copies of records.

Theory that matters here

Search systems revolve around inverted indexes, tokenization, analyzers, scoring, relevance ranking, faceted filtering, and refresh latency.

Implementations

  • Elasticsearch — distributed search and analytics engine built on Lucene.