I am using sxa search result for rendering the service items which contain coordinates(lat-lang).
We have got a new requirement where the same services may be available in different locations. Hence we have a multi-list field that will contain the available locations.
Upon indexing in SOLR, I am indexing the coordinates of all available locations into coordinates_rpt as a multivalued field.
We have customized the SOLR to find the nearby available location for any center point and return the same, hence we should be able to get the distance sent by SOLR and display it in search results along with another item field.
As we are using many SXA OOTB search components for this search functionality we want to retain the existing search result behavior and just tweek the result alone.
Any help please?
My first thought would be -as Michael mentioned- the processSearchItems pipeline as that enables you to add data to an object in the SearchItem result list. Problem with this pipeline though (maybe an idea for the SXA team to change this in the future as this question does pop up often) is that you don't have access to the solr results (as far as I know).
So I do think you will need to create you own version of the Sitecore.XA.Feature.Search.Controllers.SearchController. Check the ootb code for the GetResults function and adjust as needed. I think you'll need:
change the object that is returned from the query
once the SearchItem objects are created, add the extra information into the available object within the SearchItem
use the information from the SearchItem with a Model variant (or o_model in Scriban)
Sorry I am bit late in updating the result of implementation. I was able to successfully complete this implementation thru pipeline customization. However to avoid any performance issue I made sure that there is no looping or any business logic involved inside the pipeline and did little scriban as well i remember. Its implemented successfully an year ago and is still stable I could see. FYI we had to sort almost 10000 services and show the one in the search card which is nearest of that particular service for the user current/provided location.@Michael thanks for the great suggestion.