Skip to main content

Dropping Words From Multi-Word Queries

When exact matching, typo correction, and compound-word handling still do not return enough results for a multi-word query, the search engine can drop query words one at a time and search with the remainder. Two settings control this — drop_tokens_threshold (when dropping happens) and drop_tokens_mode (which words are dropped first) — both under the typo_tolerance attribute of a search profile.

Dropping Words From Multi-Word Queries (drop_tokens_threshold)

When a multi-word query returns fewer results than drop_tokens_threshold (default 1), the engine progressively drops query words and searches with the remainder. This rescues queries where one word is wrong or simply absent from your catalog.

Consider a product named Mini Electric Drill and the query drill qwxzv, where qwxzv matches nothing:

drop_tokens_thresholdSearch for drill qwxzv matches
1 (default)Mini Electric Drill — the unmatched word is dropped
0Nothing — dropping is disabled, every query word must match
{ "typo_tolerance": { "drop_tokens_threshold": 0 } }

Setting drop_tokens_threshold: 0 switches word dropping off entirely, no matter what drop_tokens_mode is set to.

Choosing Which Words to Drop (drop_tokens_mode)

drop_tokens_mode controls which end of the query loses words first:

  • right_to_left (default): drop the last word first.
  • left_to_right: drop the first word first.
  • both_sides:N: drop from both ends in turn, returning matches found from each side — but only for queries of N words or fewer. Longer queries fall back to right_to_left.

Consider two products, garden and shovel, and the query garden shovel (no product contains both words):

drop_tokens_modeSearch for garden shovel matches
right_to_left (default)gardenshovel is dropped first
left_to_rightshovelgarden is dropped first
both_sides:2garden and shovel — the 2-word query is within the limit, so both ends are tried
both_sides:1garden — the 2-word query exceeds the limit of 1, so it falls back to right_to_left
{ "typo_tolerance": { "drop_tokens_mode": "both_sides:3" } }
Ask External AI