Phrase boosts reward documents where the words a user typed appear close together. They never add or remove a document; they only move the good ones up.
Phrase fields do not filter anything. They add optional clauses on top of the term matching, so a document that happens to contain the words in sequence scores higher than one where the same words are scattered across a page.
The same four-word query, seen by each phrase parameter.
pf — the whole query as one phrase
One clause, containing every term in order. It only fires when the complete phrase is present, which makes it the strongest and the rarest of the three.
pf2 — every adjacent pair
The query is shingled into bigrams and each pair becomes its own clause. This is what keeps long queries useful: the full phrase almost never matches, but two-word fragments do.
pf3 — every adjacent triple
The same idea with trigrams. Useful when queries are long enough for three-word fragments to carry meaning.
All three, on the same request, with the clauses Solr built for them:
q=alpha beta gamma defType=edismax qf=title^2 text pf=title^5 ps=2 pf2=title^3 ps2=1 pf3=title^2 parsedquery: +(DisjunctionMaxQuery((text:alpha | (title:alpha)^2.0)) DisjunctionMaxQuery((text:beta | (title:beta)^2.0)) DisjunctionMaxQuery(((title:gamma)^2.0 | text:gamma))) DisjunctionMaxQuery(((title:"alpha beta gamma"~2)^5.0)) (DisjunctionMaxQuery(((title:"alpha beta"~1)^3.0)) DisjunctionMaxQuery(((title:"beta gamma"~1)^3.0))) DisjunctionMaxQuery(((title:"alpha beta gamma"~2)^2.0))
pf1, and no ps1. Solr ignores unknown request parameters silently, so a pf1 sitting in a request handler looks harmless and does exactly nothing — the parsed query above gains no clause when it is added. A one-word query has no phrase to boost, and every phrase clause collapses to empty: +DisjunctionMaxQuery((text:alpha | (title:alpha)^2.0)) (). If single-word queries need help, raise the qf weight of the field that matters, or elevate the document.02 · ps, ps2, ps3 — how much drift is still a phrase
Slop is the number of position moves needed to turn the document's wording into the query phrase. One word in between costs one. Swapping two adjacent words costs two. A phrase clause matches when the required moves fit inside the slop you allowed.
Everything to the left of the threshold still earns the phrase boost. Everything to the right earns nothing.
| Parameter | Applies to | When not set |
|---|---|---|
ps | The pf clause | Zero: the phrase must be exact. |
ps2 | The pf2 clauses | Falls back to ps. |
ps3 | The pf3 clauses | Falls back to ps. |
The fallback is visible in the capture above: ps3 was never sent, and the pf3 clause came out as "alpha beta gamma"~2, borrowing the ps=2 set for pf. Raising slop is the cheapest way to make phrase boosting meaningless — at a large enough value every document containing the words counts as a phrase match, and the ranking flattens back to plain term matching.
The eDisMax query parser
pf, pf2, pf3 and ps: phrase boosting and slop (this page)