I want to change SXA search box algorithm to support exact matching, when I search with a work like "National Day", it returns results that contains "National" or "Day" or "National Day", I want it to returns results that contains "National Day" as a whole only.


This is not possible out of the box, although we've been discussing this today and there is a chance we will change it in future releases.

If you want to change it on your own you need to implement your own SearchService. It might sound scary but in fact, you just need to inherit from SXA SearchService and override ContentPredicate() method. Take a look at original implementation, you will notice that we are using there Contains LINQ method which is comparing search query with AggregatedContent field. Probably you just need to replace Contains with Equals.

After this just replace SXA implementation of ISearchService with your one in the DI container.

| improve this answer | |
  • Thank you so much, I will try to implement my own service. – Mohamed Mosa Sep 13 '18 at 20:24

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.