Querylight TS Demo

Phrase Search and Slop

Match analyzed terms in sequence, with optional movement tolerance, using the JSON DSL first.

Back to docs search

Reference Entry

Phrase Search and Slop

Lexical Querying · querying · order 30

Match analyzed terms in sequence, with optional movement tolerance, using the JSON DSL first.

Phrase Search and Slop

match_phrase checks whether analyzed terms occur in order. The class form is still available as the equivalent internal TypeScript API.

Exact phrase

{
  "query": {
    "match_phrase": {
      "body": {
        "query": "vector search"
      }
    }
  }
}

Equivalent internal TypeScript API:

import { MatchPhrase } from "@tryformation/querylight-ts";

const exact = new MatchPhrase({ field: "body", text: "vector search" });

Phrase with slop

Slop allows nearby terms to count even when there is a little distance between them.

{
  "query": {
    "match_phrase": {
      "body": {
        "query": "portable json index state",
        "slop": 2,
        "boost": 2
      }
    }
  }
}

Good queries to try in the demo

  • "portable json index state"
  • "vector search"
  • "phrase search"

Learn more