Skip to main content
The q parameter on GET /v1/cases/search accepts plain words, exact phrases, and boolean queries. The API automatically picks the right matching strategy based on the shape of your input.

The three modes

The API inspects your query and routes it to one of three search modes: You don’t have to pick — just write your query and the API does the right thing. The detection is purely string-based: "..." triggers phrase mode, the literal tokens AND, OR, or NOT trigger boolean mode, otherwise you get match mode.
Tokenised and matched against case_name (3× weight) and doc_text. Results are ranked by relevance score. Word order is not significant; both words don’t have to appear in the same sentence.

Exact phrase

Wrap the whole query in double quotes to require the words to appear adjacent and in order:
Phrase mode is the right choice for legal terms of art, statutory phrases, case names, or anything else where word order matters.

Boolean operators

Use AND, OR, and NOT (uppercase, with whitespace around them) to combine terms. Parentheses group sub-expressions:
The presence of any boolean operator switches the API into boolean mode, which unlocks the full grammar:
Prefer uppercase AND/OR/NOT. The API also accepts title- or mixed-case operators such as And, but lowercase and is still treated as the word “and” so ordinary prose searches keep working.

Worked example

Find judgments mentioning wednesbury unreasonableness in a public-law context, but not pure tax cases:

Field scoping with scope

By default, the search runs across both case_name and doc_text. To narrow the search to one field, pass scope: Field scoping is independent of mode — phrase and boolean queries both honour scope. Inside the boolean mode you can also do per-clause field scoping with field:value:

Fuzzy matching

Plain (match-mode) queries against scope=case_name automatically enable fuzziness: AUTO — typos within Levenshtein edit distance 1–2 still match. This is useful for case names (people misspell party names constantly) but is deliberately not enabled for doc_text searches, where it would drown specific legal terms in near-misses.
For controlled fuzzy matching in boolean mode, append ~N to a term (where N is the maximum edit distance, 0–2):

Filters: court and date range

Filters are applied after the text query. They narrow the candidate set without affecting relevance scoring.

court — comma-separated list of court codes

Multiple courts are OR’d together. See the Identifiers guide for the full list of court codes.

start / end — ISO dates

Both are optional and inclusive, in YYYY-MM-DD format. start must be on or before end.

Sorting and pagination

The API caps offset + limit at 10,000 — requests above that are rejected with 400 pagination_too_deep. If you need to walk further into the corpus than that, narrow your search with court / date filters, or contact us for a bulk export.

Response: highlights

Search results include per-hit highlights showing which snippets matched:
Matched terms are wrapped in <em>...</em> tags. Snippet fragments are up to 300 characters each, with a maximum of 3 fragments per result for doc_text and 1 for case_name.

Tips

  • Start narrow. Use scope=case_name first if you know the parties — it’s the cheapest query and fuzzy by default.
  • Phrases beat AND. "strict liability" is more precise than strict AND liability, which would match documents mentioning both words anywhere.
  • Don’t paginate beyond offset + limit = 10000. The API will reject it with 400 pagination_too_deep. Use filters to narrow, not pages to walk.
  • Rate limit applies per request, not per page. A search returning 100 results costs the same as one returning 1. Prefer larger pages.