eDisMax pf pf2 pf3 and ps - Phrase Boosting and Slop

Configuration

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.

ancientphilosophyofmindthe querypfwhole querypf2adjacent pairspf3adjacent triples

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))
There is no 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.

searching for the phrase ancient philosophyancientphilosophyancient greekphilosophyphilosophy,ancientfurther apart,or reversed tooSLOP COST0123 and upps=2still counted as a phraseno phrase boost

Everything to the left of the threshold still earns the phrase boost. Everything to the right earns nothing.

ParameterApplies toWhen not set
psThe pf clauseZero: the phrase must be exact.
ps2The pf2 clausesFalls back to ps.
ps3The pf3 clausesFalls 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)