liveBook · Manning

Non-text field

As explained in Elasticsearch in Action, Second Edition

A non-text field stores values as structured, non-tokenized data rather than as analyzed full-text content.

A non-text field stores structured values as they are: Elasticsearch does not split them into tokens or normalize them with synonyms or root words. Numeric, date, keyword, and constant-like fields fit this model. section 9.2.1 section 2.4

Use non-text fields for structured search, where a value either matches or does not. Term-level queries target these exact values instead of calculating relevance; enumerated text such as CREATED or CANCELLED can also work. section 9.2.1 section 8.9

Book fields and an exact movie query

A book document can contain "edition": 3, "amazon_rating": 4.7, and "release_date": "2017-12-27". Elasticsearch derives these as long, float, and date fields. For a movie title stored as analyzed text, this query does not match the original phrase because term queries compare the supplied value directly with indexed tokens: GET movies/_search { "query": { "term": { "title": "The Godfather" } } } Use a term query on a non-text field, or on text deliberately modeled as an enumeration or constant; use full-text search for ordinary prose. section 9.2.2 section 2.4

Listing 9.2 Using a term-level query on a text field
GET movies/_search
{
  "query": {
    "term": {
      "title": "The Godfather" 
    }
  }
}

Run the movie search request to observe exact term matching against an analyzed title. section 9.2.2

How Elasticsearch in Action, Second Edition covers it

How deep it goes
Defines tokenization and normalization behavior, inferred types, and exact-query consequences, but does not detail mapping configuration.
Examples
Uses book edition, rating, and release date fields plus a movie title term-query request.
What it assumes
Assumes basic Elasticsearch indexing and search, while introducing tokenization, normalization, inferred field types, and structured-versus-unstructured search.
What you can do after
Apply term-level queries confidently to exact structured values and recognize when full-text search is required instead.
How it connects
Connects non-text fields with structured search, term-level queries, full-text search, relevance, tokenization, and Elasticsearch mappings.

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.