SXA boosting rules are not applied properly


Description

Adding boosting rules for a search scope in an SXA site might lead to boosting rules not being applied and the following exception appearing in the logs:

WARN Results endpoint exception
Exception: System.NotSupportedException
Message: Invalid Method Call Argument Type: Field - FieldNode - Field: _name - System.String. Only constant arguments is supported.
Source: Sitecore.ContentSearch.Linq
at Sitecore.ContentSearch.Linq.Parsing.ExpressionParser.ValidateMethodCallArguments(IEnumerable`1 arguments)
at Sitecore.ContentSearch.Linq.Parsing.ExpressionParser.EvaluateMethodCall(MethodCallExpression methodCall)
at Sitecore.ContentSearch.Linq.Parsing.ExpressionParser.VisitUnary(UnaryExpression expression)
at Sitecore.ContentSearch.Linq.Parsing.ExpressionParser.VisitBinary(BinaryExpression expression)
at Sitecore.ContentSearch.Linq.Parsing.ExpressionParser.VisitWhereMethod(MethodCallExpression methodCall)
at Sitecore.ContentSearch.Linq.Parsing.ExpressionParser.VisitCountMethod(MethodCallExpression methodCall)
at Sitecore.ContentSearch.Linq.Parsing.ExpressionParser.Parse(Expression expression)
at Sitecore.ContentSearch.Linq.Parsing.GenericQueryable`2.GetQuery(Expression expression)
at Sitecore.ContentSearch.Linq.Parsing.GenericQueryable`2.Execute[TResult](Expression expression)
at Sitecore.XA.Feature.Search.Controllers.SearchController.GetResults(QueryModel model)

Solution

To resolve the issue, consider one of the following options: