Edge Rewrite
// HTMLRewriter · presentation

This page was redesigned at the edge.

Cloudflare fetched the original article and streamed it through HTMLRewriter to apply an entirely new visual system without rebuilding the source page.

// request.cf · coarse context

A page that knows where it met you.

Only coarse request metadata is shown. This demo does not display or persist visitor IP addresses.

Country
US
Cloudflare location
CMH
Connection
HTTP/2
Language
Not provided

Ray ID: a252127e8a738682

Jump to content

Slop (search algorithms)

From Wikipedia, the free encyclopedia

Slop (or slop amount) is a parameter in information retrieval and full-text search algorithms that defines the maximum number of positions words in a query are allowed to move to match a document. It transforms a strict "phrase match" into a "proximity search," allowing for missing words, extra words, or variations in word order within a specified "edit distance" of terms.[1]

The term is primarily used in Apache Lucene-based search engines, such as Elasticsearch and OpenSearch.[2]

Mechanism

[edit]

In a standard phrase match (slop of 0), the search engine requires tokens to appear in the exact sequence stored in the inverted index. When a slop value is applied, the algorithm calculates the number of "moves" required to rearrange the document's terms to match the query's terms.

Word transposition

[edit]

A notable characteristic of slop in Lucene-based systems is how it handles reversed word order. To swap the positions of two adjacent words (e.g., matching "fox quick" against the query "quick fox"), a slop of at least 2 is required.[3] This is because:

  1. The first move brings the two words into the same position.
  2. The second move shifts one word past the other to complete the transposition.

Examples

[edit]

Given the search query "quick fox":

  • Slop 0: Matches only the exact phrase "quick fox".[4]
  • Slop 1: Matches "quick brown fox" (the word "brown" is skipped, requiring 1 move).
  • Slop 2: Matches "quick brown lazy fox" (2 moves) or the reversed "fox quick" (2 moves).

Applications

[edit]

Slop is used to increase the recall of search results by accounting for human error, varying writing styles, or the presence of stop words that may have been omitted from the index. It allows developers to balance the precision of a phrase search with the flexibility of a keyword search.

See also

[edit]

References

[edit]
  1. "Match phrase query". OpenSearch Documentation. OpenSearch. Retrieved 2026-02-27.
  2. "Match phrase query". Elastic Docs. Elasticsearch. Retrieved 2026-02-27.
  3. "Elasticsearch Part-2: Match Phrase Query". Medium.com. 2024-10-21. Retrieved 2026-02-27.
  4. "Phrase Match with Slop in Milvus 2.6: How to Improve Phrase-Level Full-Text Search Accuracy". milvus.io. 2025-12-29. Retrieved 2026-02-27.