Suffix

Suffix query

/ Suffix, / Query

Suffix query #

Returns documents that contain terms ending in the provided value. This is the mirror of the prefix query; like a leading wildcard, it is more expensive than a prefix match.

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

How it works #

A term dictionary is sorted by its beginnings, so a prefix can seek directly to its subtree — but a suffix cannot. The engine therefore walks the whole dictionary of the field and keeps the terms that end with the value, then unions their postings lists exactly like a should of term queries. The cost is proportional to the number of distinct terms in the field, not to the number of matches, which is why the suffix query is marked more expensive than prefix.

...