eDisMax mm - Minimum Should Match Explained

Configuration

mm is the only eDisMax parameter that changes which documents are in the result set. Boosts change the order; mm changes membership.

mm (minimum should match) is the recall/precision dial. It decides how many of the query terms a document must contain before it is allowed into the result set at all. Set it too high and long queries return nothing; too low and every document containing one common word turns up.

mm=2<75%filled squares are the terms a document must contain1122324353647586TERMS TYPEDMUST MATCH

The same setting, read across query lengths: short queries stay strict, long queries relax.

FormExampleMeaning
Positive integer3At least three clauses must match.
Negative integer-1All clauses but one.
Percentage75%Three quarters of the clauses, rounded down.
Negative percentage-25%At most a quarter of the clauses may be missing, rounded down.
Conditional2<75%Up to two clauses, all are required. Above two, apply 75%.
Chained2<-1 5<40%Conditions are read in order of clause count; the last one that applies wins.

The number Solr actually enforces shows up at the end of the parsed query as ~N. Real captures:

mm=75%     q=alpha beta gamma          ->  (... alpha ... beta ... gamma)~2
mm=75%     q=alpha beta gamma delta    ->  (... four clauses ...)~3
mm=2<75%   q=alpha beta                ->  (... alpha ... beta)~2
mm=2<75%   q=alpha beta gamma          ->  (... three clauses ...)~2
mm=-25%    q=alpha beta gamma delta    ->  (... four clauses ...)~3

Note the rounding: 75% of three terms is 2.25, and Solr requires two, not three. Percentages always round down. Note the conditional as well — with 2<75% a two-word query needs both words, because the rule only starts applying above two clauses.

If mm is not set at all, the effective default depends on q.op: AND behaves as 100%, OR as 0%. Leaving both unset is how a search ends up returning everything that contains any one word.

The eDisMax query parser

mm: how many words must match (this page)