0

I'm using Sitecore 9.1 and SXA 1.8, I'm using SXA boosting rule of where the field contains Search Box query, this rule doesn't work when the Search Box query is multiple words that are not in order.

For example if I have item that its name is "Drive a car" that I'm applying the boosting rule on it, if I search with "drive a", the boosting rule will work, if I search with "car drive", it won't.

After investigation I found out that Solr doesn't support wildcard searches within single terms.

So I'll have to create a predicate for boosting word by word as the SXA do in its Search Service.

I tried extending the SXA Boosting Service, but I couldn't know where or how add the predicate. Is there is any other solution for this like Solr configuration, or it's not duable.

1

I'm not sure if I exactly known what you are trying to achieve but here are some details which might be helpful.

The BoostingService has two important methods:

  • IQueryable<ContentPage> BoostQuery(IList<Item> boostingItems, string searchQuery, Item contextItem, IQueryable<ContentPage> queryable)
  • IQueryable<ContentPage> BoostQuery(Field boostingField, string searchQuery, Item contextItem, IQueryable<ContentPage> queryable)

Those methods accept boosting rules (list of boosting rule items or the field itself), user query, context item and important predicate itself - IQueryable<ContentPage> queryable.

If you will investigate the service more you will notice that the magic is done in the BuildConditionPredicates method. Base on the boosting rule it is building the predicate in a different way. E.g.:

enter image description here

You will need to:

  1. Implement your own boosting rule where you could provide needed parameters.
  2. Override the BoostingService and extend the BuildConditionPredicates to process your custom boosting rule.
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.