Replace
<str name="classname">solr.DirectSolrSpellChecker</str>
with
<str name="classname">solr.WordBreakSolrSpellChecker</str>
in <searchComponent name="spellcheck">
node on solrconfig.xml
rebuild dictionary and request spell checking like:
var results = ctx.GetSpellCheck(new SolrQuery(Term), new SpellCheckHandlerQueryOptions()
{
SpellCheck = new SpellCheckingParameters()
{
Count = 10,
Build = true,
Collate = true
}
});
if (results != null && results.SpellChecking != null && results.SpellChecking.Count > 0)
{
var words = terms.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
if (words.Length < 2)
{
return results.SpellChecking.SelectMany(x => x.Suggestions);
}
var correct = "";
foreach (var w in words)
{
var suggest = results.SpellChecking.FirstOrDefault(x => x.Query.Equals(w));
if (suggest != null && suggest.Suggestions.Any())
{
correct += suggest.Suggestions.First() + " ";
}
else
{
correct += w + " ";
}
}
return new List<string> { correct.Trim() };
}
return new List<string>();