A text field holds unstructured content such as a news title, synopsis, product attribute, or movie title for full-text search. During indexing, Elasticsearch analyzes its value rather than storing it only as one untouched string. Analysis turns text into terms in an inverted index, allowing searches to match words despite differences in case, word order, common words, spelling, synonyms, abbreviations, or root forms when the chosen analyzer supports them. section 7.1.2 section 3.1.2
Text analysis has two main jobs: tokenization splits input into tokens, and normalization transforms tokens. An analyzer packages one tokenizer with optional character filters and token filters. Elasticsearch uses the standard analyzer by default when no analyzer is specified; custom and language analyzers let indexing reflect application-specific search needs. The query text for full-text search is normally analyzed too, using the indexing analyzer unless a different search analyzer is configured. section 7.9 section 10.5.3
From a sentence to searchable terms
A synopsis such as “Peter Piper picked a peck of Pickled-peppers!” can be tokenized and normalized into [peter, piper, picked, a, peck, of, pickled, peppers]. Lowercasing and punctuation removal mean a search for terms such as Peter or Peppers can match the indexed content without requiring the original capitalization or punctuation. section 3.1.2
Choose a text field for content people search as language. Use a non-text field such as keyword, numeric, date, or Boolean data for exact structured matching. This distinction matters because term-level queries are not analyzed: a term query for “The Godfather” does not match a title indexed as separate lowercase tokens “the” and “godfather.” Text fields containing short enumerations or constants can be an exception, but unstructured text is a poor fit for term queries. section 9.2.1 section 9.2.2 section 8.9
Listing 9.2 Using a term-level query on a text field
GET movies/_search
{
"query": {
"term": {
"title": "The Godfather"
}
}
}
The request searches a text-mapped movie title with a term query. It returns no result because the complete input is not one indexed token; use full-text search for ordinary title text instead. section 9.2.2
For ordinary full-text retrieval, use a match query against a text field. Match queries accept one or more words and analyze the search value, so capitalization differences such as JAVA, java, and jaVA can produce the same result when the standard analyzer is used. Full-text results are relevance-scored, unlike the binary behavior associated with structured term-level searching. section 10.5.1 section 10.5.3 section 8.9
