2

Sitecore 9.3

I want to boost a result based on a field containing a keyword and it's working absolutely fine with the below query.

var keywordQuery = PredicateBuilder.True<SearchResultItem>();
keywordQuery = keywordQuery.Or(item => item.ShortTitle.Contains(keyword)).Boost(5);
keywordQuery = keywordQuery.Or(item => item.LongTitle.Contains(keyword)).Boost(4);

Now, along with field boosting, I also need to get the result based on lat/long provided with the query. Having said that, if there are two records with the same boost value or score, the nearest record should come first.

I have added below lines with this query, but I think, it's not working.

var queryable = context.GetQueryable<SearchResultItem>().Where(query);
queryable = queryable.OrderByDistance(s => s.MyCoordinates, new Coordinate(lat, lng));

Any pointers?

2
  • Can you make sure the template you are using – to store coordinates, inherit from /sitecore/templates/System/Geospatial/Coordinate? and return type for the "MyCoordinates" field is "coordinate" in the config? Jun 13, 2020 at 8:02
  • Yes. it is the same and working individually when no boosting is there. But with field boosting, it is not working. Jun 13, 2020 at 14:12

0

Your Answer

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

Browse other questions tagged or ask your own question.