Prefix

Prefix query

/ Prefix, / Query

Prefix query #

Returns documents that contain a specific prefix in a provided field.

Use it when the values share a known beginning — a hostname family, an ID scheme, a URL section — and you want every term that starts with it.

Inside a nested query: not supported yet — the clause is rejected with an HTTP 400 naming the offending clause.

How it works #

The prefix is expanded against the inverted index’s term dictionary. Because the dictionary is kept in sorted order, the expansion is an ordered seek to the first term greater than or equal to the prefix, followed by reading the subtree of terms that start with it — no scan of the whole dictionary. Each expanded term’s postings are then unioned (OR semantics), exactly as if you had written a should of term queries.

...