SteelReed

Search

Search posts, questions…

Data Modeling & ScalingQuestion 32 / 35

Junior

What is an inverted index in Elasticsearch, and how do text and keyword differ?

Short answer

An inverted index maps each term to the list of documents containing it, like a book's index. text goes through an analyzer for full-text search; keyword keeps the string as-is for exact filtering, sorting and aggregations.

text: analyzerkeyword: as-isMáy Lạnh Minimáy · lạnh · minimatch: full-textMáy Lạnh Miniterm, sort, aggregate

3 points to say:

  1. Inverted index: term → list of documents; finding a word is a term lookup, not a scan of every document.
  2. text is analyzed for match; keyword is the raw string for term, sort, aggregate; the analyzer must be the same at index and search time.
  3. Vietnamese: folding strips accents + an accented sub-field that gets boosted.

Keep reading the deep dive

Create a free account to read the full explanation and follow-up questions, mark questions as studied and review them on a schedule.