For agents: Read llms.txt for the complete documentation and public content index. Request this page as Markdown.

Skip to main content
Ceisium logo Ceisium
A continuous text signal passes through boundary planes and becomes separate token blocks.
A continuous text signal passes through boundary planes and becomes separate token blocks.

A continuous text signal passes through boundary planes and becomes separate token blocks.

What Is Tokenization in Search?

Learn how search engines split and normalize page text and queries into searchable terms, and why those choices can decide which pages reach ranking.

Your documentation contains a page named Rotate an API-key. The hyphen is intentional. A user searches for API keys.

The page is relevant, but search does not show it. You can first suspect the ranking settings. However, the problem can occur before ranking.

The search engine must convert the page text and query into comparable terms. Tokenization decides where one token ends and the next token starts.

Tokenization divides text into searchable pieces. Each piece is a token.

Search tokens are intermediate pieces in a text-analysis process. They are different from the subword tokens that a language model uses.

One configuration can produce these tokens:

TEXT
Page:   Rotate an API-keyTokens: [Rotate] [an] [API] [key]Query:  API keysTokens: [API] [keys]

The tokenizer uses spaces and the hyphen as boundaries. It does not make API and api equal. It also does not connect keys to key.

Lowercase conversion can make API and api equal. Stemming can connect keys to key.

A different tokenizer can keep API-key as one token. Another process can remove the hyphen first and produce APIkey.

Tokenizer settings determine which terms are available for matching. Therefore, punctuation can affect search results.

The tokenizer selects boundaries. Lowercase conversion and optional filters operate in later analysis steps.
A black llama-shaped character operates a token punch on an API-key strip, with separate lowercase and optional-filter stations.

The tokenizer selects boundaries. Lowercase conversion and optional filters operate in later analysis steps.

Tokenization is one part of text analysis

People sometimes call the complete analysis process tokenization. This article separates the stages so that you can examine each operation:

TEXT
Page:  characters → optional character filters → tokens → optional token filters → indexed termsQuery: characters → optional character filters → tokens → optional token filters → query terms

Character filters change text before the tokenizer selects boundaries. Token filters operate after tokenization. They can change, remove, or add tokens.

This example shows the stages:

TEXT
Page: Rotate an API-keyTokenize:           [Rotate] [an] [API] [key]Lowercase:          [rotate] [an] [api] [key]Optional stopwords: [rotate]      [api] [key]Query: API keysTokenize:           [API] [keys]Lowercase:          [api] [keys]Optional stemming:  [api] [key]

A token is output from the tokenizer. An indexed term is the final page-side form that the index stores.

A query term is the comparable query-side form. A token filter can remove a token or transform it into one or more terms.

Each analysis step has one purpose:

  • Lowercase conversion can make API and api comparable.
  • A stop-word filter can remove a common word such as an.
  • A stemmer or lemmatizer can reduce keys to key.
  • A synonym filter can connect different expressions.

These filters are optional. Stop-word removal can damage names and phrase searches. Stemming can also combine words that a site must keep separate.

Select the analysis steps that fit your content and your users.

The page and query need compatible terms

An analyzer is the complete analysis process. It has optional character filters, one tokenizer, and optional token filters.

The analyzer processes page fields when the search engine indexes a page. The engine stores the final terms in an inverted index .

The analyzer also processes the query when the user searches.

The page analyzer and query analyzer can be different. However, both analyzers must produce compatible final terms for a lexical match.

Compatible terms must meet in the index. The analyzers can differ, but their terms must be compatible where matching is necessary.

For example, the index can store api-key as one term. If the query produces api and key, a simple lexical lookup can miss the page.

A field is one searchable part of a document. A title, body, or identifier can each be a separate field.

Different fields can use different analysis settings:

  • A body field can split api-key so that key can find the page.
  • An identifier field can keep api-key because the punctuation has meaning.
  • The system can index both forms when both search behaviors are necessary.

There is no universal rule that removes all punctuation. The correct boundary depends on the purpose of the text.

Tokenization occurs before ranking

A candidate is a page that a ranker can put in order. A lexical search path has this basic form:

TEXT
Page text  → analysis → indexed terms ┐                                         ├→ candidate pages → rankingQuery text → analysis → query terms   ┘

Shared terms help the engine find candidates in the inverted index. A ranking method such as BM25 then puts those candidates in order.

A ranker cannot promote a page outside its candidate set. Ranking can only order pages that term-based retrieval supplies.

Search engines use different candidate rules. An engine can accept any query term, all query terms, or a specified minimum.

The candidate rules use the terms that text analysis produces.

Compatible terms admit a page to the lexical candidate set. Ranking can only order the candidates that it receives.
Page and query term strips align on api and key to open a candidate gate before ranking.

Compatible terms admit a page to the lexical candidate set. Ranking can only order the candidates that it receives.

A hybrid system can add another retrieval path. Tokenization still determines which terms the lexical path can match.

Not every mismatch is a tokenization problem

A missing page can have many causes. Find the first analysis stage that breaks the useful match.

Page and query formsMechanism to inspect
API and apilowercase conversion
keys and keystemming or lemmatization
API-key and API keydelimiter handling
apikey and api keysplit and join handling
kdy and keytypo or fuzzy matching
adjacent and separated api keyphrase or proximity matching

Split and join handling connects forms such as apikey and api key. Phrase matching checks whether terms occur in sequence.

Proximity matching limits the distance between terms. Some implementations also permit the terms in either order.

The word exact can describe different comparisons:

  • Exact string: The original characters are the same.
  • Exact analyzed term: The final analysis terms are the same.
  • Exact phrase: The analyzed terms occur in sequence with no permitted gap.
  • Fuzzy match: A separate rule permits a small spelling difference.

After lowercase conversion, API and api can produce the same analyzed term. Their original strings are still different.

Unicode also affects analysis

Some characters look the same but use different internal representations. Two copies of café can use different character sequences for é.

Unicode normalization can make those representations consistent. Accent folding is a different process. It changes café to cafe and removes information.

Languages also use different word boundaries. Thus, an English whitespace rule is not a universal tokenizer.

Character normalization and token boundaries are configuration choices. They are not laws of text.

How to debug a tokenization miss

Use this sequence when a correct result does not appear:

  1. Record the exact page text and the exact query.
  2. Examine the tokens and final terms from both analyzers.
  3. Find the first stage that makes the useful terms incompatible.
  4. Decide whether the field must split, preserve, or store more than one form.
  5. Reindex the content after a change to page-side analysis.
  6. Measure missed relevant pages and new unwanted pages.
Fix the first stage that breaks the match. Fix the first lexical stage that breaks the match. Ranking cannot restore missing term evidence.

This sequence shows whether the failure occurs in tokenization, normalization, candidate retrieval, or ranking.

Summary

Tokenization selects the boundaries in text. Other steps control lowercase conversion, stop words, stemming, synonyms, fuzzy matching, and ranking.

Before you change the rank of the API-key page, ask one question:

Did the page and the query produce compatible terms?

If the page becomes a candidate, ranking can do its work. Read about inverted indexes to learn how search stores the terms.

Then read about BM25 to learn how lexical search ranks the candidates.

Next reads