liveBook · Manning

Text data type

As explained in Elasticsearch in Action, Second Edition

The text data type is an Elasticsearch mapping type for analyzed textual content used in full-text search.

Use the text data type for human-readable content such as movie titles, blog posts, reviews, news, tweets, and log messages. Elasticsearch analyzes each text field before persisting it, preparing the content for full-text search. section 4.5.1 section 4.4

A text mapping is straightforward: "field": { "type": "text" }. During indexing, an analyzer can remove punctuation and special characters, tokenize the text, normalize case, stem words, and apply other natural-language rules. Elasticsearch uses the standard analyzer by default. section 4.5.1

Map a movie title for search

PUT movies { "mappings": { "properties": { "title": { "type": "text" } } } } The title is indexed as analyzed text, so queries can search its analyzed terms rather than requiring the original title as one unchanged value. section 4.5.1

Choose related mapping features according to how the field will be searched:

  • Add a keyword multi-field when the same value also needs structured, unanalyzed access. section 4.7
  • Add completion when the field must support completion-oriented access, using dot notation for the additional type. section 4.7
  • Use token_count as an additional field when searches need the analyzed word count, such as titles containing four words. section 4.5.1
  • Dynamic mapping can infer a string field as text, but explicit mappings make the intended schema clear. section 4.2 section 4.5.1
"The movie was sick!!! Hilarious :) :) and WITTY ;) a KiLLer 👍"

Inspect the movie-review input that is transformed during analysis before its searchable terms are stored. section 4.5.1

How Elasticsearch in Action, Second Edition covers it

How deep it goes
Explains mapping, tokenization, filtering, normalization, stemming, and multi-fields, while deferring detailed text analysis.
Examples
Uses a movie review, movie titles, email subjects, and analyzed title word counts as concrete mapping and search examples.
What it assumes
Assumes document fields and mappings, while introducing text as a core Elasticsearch data type and explaining its basic indexing behavior.
What you can do after
Build it from scratch by defining analyzed fields and configuring keyword, completion, or token_count multi-fields.
How it connects
Connects text with analyzers, text analysis, keyword, completion, token_count, multi-fields, and dynamic mapping.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Elasticsearch in Action, Second Edition. The section links point to the parts of the book it draws on.