POST /us/statutes/search ranks.
It does not enumerate.
Most of what follows depends on that difference, so settle it before you design a pipeline around search.
In short:
- Search ranks sections by relevance, up to a bounded number of results.
matchTypepicks how the query is read: ranked (any), narrowed (all,phrase) or an exact expression (boolean).- Filters are applied before retrieval, so scoping improves recall.
The ranking model
Search is hybrid. Two retrieval legs run in parallel over the same corpus:- a semantic leg, which matches on meaning, so a section can rank for a question that shares none of its wording
- a keyword leg, which matches on the terms themselves
actStatus are demoted rather than dropped, so a repealed provision can still appear, ranked below live law.
See Status and currency for how to filter those out entirely.
A query shaped like a citation resolves directly to that section at rank 1.
Passing 42 U.S.C. § 1983 as your query is a lookup.
matchType
matchType is the exact-match control.
Operators are plain words in every mode except boolean: in any, all and phrase, AND, OR, NOT, quotes, proximity, wildcards and field syntax are ordinary text.
What counts as ordinary text outside boolean
What counts as ordinary text outside boolean
In
any, all and phrase, the query string is passed to retrieval as written.
It is not parsed as an expression.So in
any mode a query like defibrillator OR cardiac arrest runs as one semantic query over that whole string, including the word OR.
When such a query looks like a Boolean expression, the response carries a queryHint saying so.allandphraseonly narrow results that ranking has already retrieved. An empty result under either means nothing we ranked for your query carried those terms, so fall back toany, or scope the query more tightly with the filters, before concluding something is missing.booleanapplies the expression while the corpus is searched, so a matching section is found wherever relevance would have ranked it. The other modes stop at 120 results. See Pagination for how deep each mode pages.
What is indexed
Search reads the full canonical text of every section. Sections are split into overlapping passages, and each passage carries a header with its corpus, jurisdiction, status, hierarchy and section title. Headings and citations are therefore searchable, not just body text, and both retrieval legs see identical content. Theexcerpt on a result is one passage, sized by excerptChars.
It is a ranking preview.
excerptChars accepts 100 to 600, and a larger value is a 422.
For the authoritative text of a section, call GET /us/statutes/section/{actId}/body.
Filters are applied before retrieval
Every scoping filter (state, corpusType, code, titleNumber, chapter, part, actStatus, yearFrom / yearTo, changedSince, and the Federal Register filters) is compiled into the query itself rather than applied to the results afterwards.
yearFrom and yearTo match on the credited amendment year, else the effective year, else the document’s own publication year.
See Response fields.
Two consequences follow:
- Narrowing does not cost depth. A search scoped to one state and one corpus type gets a full-depth pool within that slice, so scoping improves recall.
- Filters combine freely with paging, and every page of a query is cut from one ranking. See Pagination.
422 rather than silently widening your query.
What a search costs
A search is charged once the ranking runs. A search that finds no good match (noGoodMatch: true) is still charged, because the ranking ran and that verdict is the answer.
A filtered search whose filters match no rows at all (an empty page) is refunded, and notes names the filters.
A page served with rankingDegraded: true (the relevance model was unavailable) is refunded and says so in notes.
includeBody adds the ordinary body price for each row that returns text, and rows whose text cannot be resolved are not charged for it.
Read creditsConsumed on the response for what a call actually cost, instead of computing it.
It can be lower than the list price, and failed or refunded work bills 0.
When search is the wrong tool
Search returns the best matches for a query, up to a bounded number of them. If your requirement is every section in a body of law rather than the most relevant ones, browse the hierarchy instead:GET /us/statutes/divisions walks codes to chapters to sections and returns every section in a container with its actId.
Browse the hierarchy
Enumerate a bounded body of law without relying on ranking.
POST /us/statutes/count takes the same scoping filters, runs no ranking, and returns an exact section count.
It accepts no query, because a count of sections matching a query would only be the size of the ranking window.
Related
Boolean search
Terms and connectors with matchType boolean.
Pagination
How deep a result set goes, and how to page it.
Best practices
Scoping, matchType, and what to cache.
Status and currency
Filtering repealed and superseded law out of results.
Build a subject corpus
Enumerate, scope, hydrate, and keep it current.

