3

Whenever I query using the Like query the Sitecore generated Solr query escapes the space characters. Here is an example:

queryable = queryable.Where(result =>
                    result["displayName"].Like(keywordArg).Boost(2.0f) ||
                    result.Name.Like(keywordArg).Boost(2.0f) ||
                    result.Content.Like(keywordArg)
                );

Generates:

(displayname_t:(Test\ Query\ Test~0.5))^2 OR (_name:(Test\ Query\ Test~0.5))^2 OR _content:(Test\ Query\ Test~0.5)

I am using Sitecore.ContentSearch.Linq 10.1.0.

My expectation would be that it does not add a backslash to the generated query.

Any Ideas?

2
  • 1
    Does it have to do with the type of analyzer used? Aug 30, 2021 at 2:36
  • I am not overriding any of the default Solr Analyzers. I am also not sure when those analyzers would be applied? I took the generated query from the Solr logs. I thought the Sitecore ContentSearch library would generate the query and then Solr would run its analyzers internally. I am not an expert with this particular pipeline though. Aug 30, 2021 at 2:56

1 Answer 1

4

I was not able to find the direct cause of this issue but I have found a possible solution.

When using the Like function with the slop parameter Like<T>(this T value, string phraseComparison, int slop), it formats the query correctly without the backslashes. From the logs: _content:("Test query Test test"~1)

I believe the phrase query is closer to what I am hoping to achieve so this should be OK.

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.