I'm using Solr 7.2.1, I'm implementing did you mean functionality using Solr spellchecker, I want the collation results to be relevant to a field, for example if I search with 'drive cay', the result will be 'drive cat' then 'drive car', of course the second option is more relevant to the user, but 'cat' word exists in the index more than 'car' so it shows first.

I need the collation that its words together occur more in a field like title field for example.

<!-- a spellchecker built from a field of the main index -->
<lst name="spellchecker">
  <str name="name">default</str>
  <str name="field">title_t</str>
  <str name="classname">solr.DirectSolrSpellChecker</str>
  <!-- the spellcheck distance measure used, the default is the internal levenshtein -->
  <str name="distanceMeasure">internal</str>
  <!-- minimum accuracy needed to be considered a valid spellcheck suggestion -->
  <float name="accuracy">0.5</float>
  <!-- the maximum #edits we consider when enumerating terms: can be 1 or 2 -->
  <int name="maxEdits">2</int>
  <!-- the minimum shared prefix when enumerating terms -->
  <int name="minPrefix">0</int>
  <!-- maximum number of inspections per result. -->
  <int name="maxInspections">5</int>
  <!-- minimum length of a query term to be considered for correction -->
  <int name="minQueryLength">3</int>
  <!-- maximum threshold of documents a query term can appear to be considered for correction -->
  <float name="maxQueryFrequency">0.00</float>
  <!-- uncomment this to require suggestions to occur in 1% of the documents  -->
    <float name="thresholdTokenFrequency">0.00001</float>

<requestHandler name="/spell" class="solr.SearchHandler" startup="lazy">
<lst name="defaults">
  <!-- Solr will use suggestions from both the 'default' spellchecker
       and from the 'wordbreak' spellchecker and combine them.
       collations (re-written queries) can include a combination of
       corrections from both spellcheckers -->
  <str name="spellcheck.dictionary">default</str>
  <str name="spellcheck">on</str>
  <str name="df">title_t</str>
  <str name="spellcheck.extendedResults">true</str>
  <str name="spellcheck.count">10</str>
  <str name="spellcheck.alternativeTermCount">5</str>
  <str name="spellcheck.maxResultsForSuggest">5</str>
  <str name="spellcheck.collate">true</str>
  <str name="spellcheck.collateExtendedResults">true</str>
  <str name="spellcheck.maxCollationTries">10</str>
  <str name="spellcheck.maxCollations">5</str>
  <str name="spellcheck.build">true</str> 
<arr name="last-components">
  • 1
    Spellchecker is not so smart, it is only responsible for mistakes correction. You should use Solr Suggester, it is more flexible. What are you looking for is Lookup Implementations of suggester (ways how suggester find relevant results). For example you can setup suggester with FuzzyLookupFactory instead of spellchecker. Read more about suggester lookup implementations here: lucene.apache.org/solr/guide/6_6/suggester.html#Tips_and_tricks
    – x3mxray
    Oct 8, 2020 at 16:30
  • I already use FuzzyLookupFactory in my auto-suggest component, the issue with the FuzzyLookupFactory that it only correct the word and suggest from the beginning of the sentence, and it works different than the spellchecker, for example if I write 'reguest', the Fuzzy one returns phrases starts with 'register' while the spellchecker returns 'request' which makes more sense Oct 8, 2020 at 18:34
  • Could you add to question definition of your "/spell" requestHandler? Oct 8, 2020 at 21:52
  • @DanAbramov I updated the question Oct 9, 2020 at 11:17

1 Answer 1


You can do it by passing spellcheck.collateParam.q.op=AND to Solr request. By default Solr use OR operator for suggestion terms collations.

You can also pass spellcheck.collateParam.mm=100% that will requre 100% of the query terms to match any document when testing collations.

From Solr official documentation:

For example, even if your regular search results allow for loose matching of one or more query terms via parameters like q.op=OR and mm=20% you can specify override params such as spellcheck.collateParam.q.op=AND&spellcheck.collateParam.mm=100% to require that only collations consisting of words that are all found in at least one document may be returned

You can also see similar question here.

How to pass additional parameters to spellchecker from SolrNet:

var results = context.GetSpellCheck(query, new SpellCheckHandlerQueryOptions
    SpellCheck = new SpellCheckingParameters
        Count = count,
        Collate = true,
    ExtraParams = new List<KeyValuePair<string, string>>
        new KeyValuePair<string, string>("spellcheck.collateParam.q.op","AND"),
        new KeyValuePair<string, string>("spellcheck.collateParam.mm","100%"),

P.S. It only makes sense if your field title_t is not tokenized.

  • Great, but how can I compare it to 'title_t' field, I think it compares it to the whole index Oct 10, 2020 at 10:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.