Running into a bit of an issue using Slop with SOLR. Previously on Lucene indexes we were able to use the .Like() method on the IQueryable result from the SearchContext. The code runs roughly like so

var results = context.GetQueryable<CustomTypeUsedBySite>().
    Where(z =>
        || z.Content.Like(queryStringFromUser, intSlopVariable));

The query that Sitecore produces to SOLR seems to ignore the integer passed in with this method and always defaults to .5 and also wraps the whole query in double quotes.

((keywords_t:("\*Auto Coverage\*"))^0.899999976158142 OR _content:("Auto Coverage\~0.5"))

I've tried manually removing the inSlopVariable and hard coding 10 in place of it and still get the .5 being set. It also changes the format used in the query when there is only one word or phrase which seems to give me a better result but still ignores the slop value.

((keywords_t:(*Coverage*))^0.899999976158142 OR _content:(Coverage~0.5))

When making a query manually I got result that I was looking for with this query

((keywords_t:("\*Auto Coverage\*"))^0.899999976158142 OR _content:("Auto Coverage"~10))

Did some digging and found someone reporting a similar issue as well (https://community.sitecore.net/developers/f/8/t/6990) but looks to be rather old.

Any help would be fantastic,


  • If you have DotPeek, the code you're looking for is in Sitecore.ContentSearch.Linq.Solr.SolrQueryMapper.VisitLike. I'll try to spelunk a bit later Feb 19, 2019 at 16:20

1 Answer 1


I believe this is a bug in Sitecore, which means you should file a support ticket with them.

It looks like the code that handles this, Sitecore.ContentSearch.Linq.Solr.SolrQueryMapper.VisitLike, returns both the actual value and the similarity as the field value. This means that if there is a space, the whole things gets quoted, which is obviously incorrect.

Additionally, that code also only takes into account the MinimumSimilarity property, not the slop, which is why you always get 0.5. That 0.5 value comes from Sitecore.ContentSearch.Linq.Parsing.ExpressionParser.VisitLike, which is the default similarity. It looks like the slop is completely ignored by the Solr query mapper. I'm not sure if Solr doesn't support slop, but if it doesn't I would personally make the Solr query mapper throw an exception if it encounters a slop. I'd bring this up with Sitecore as well.

  • Tyler, please let me know what Sitecore says about this issue. I'm interested to know what the resolution is Feb 20, 2019 at 15:02
  • 1
    Opening the Support ticket today but also I have a work around that gets past this issue. Here's the code: z.Content.MatchWildcard("\"" + queryStringFromUser + "\"\\~" + intSlopVariable.ToString()) This takes the manually constructed string as a literal and prevents the query from being wrapped in quotes.
    – Tyler.S
    Feb 20, 2019 at 17:23

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.