1

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?

2
  • Would it be possible to use the pipeline processSearchItems to alter the output? doc.sitecore.com/developers/sxa/19/… Jun 13, 2021 at 14:34
  • @MichaelWest in processsearchitem pipeline provides properties Items and SearchItem and they are not direct solr values, hence not sure if its possible to add the solr returned distance here to the result before rendering in the search result. Jun 17, 2021 at 5:11

2 Answers 2

0

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)
2
  • sure I will try it and let you know soon. Thank you. Jun 15, 2021 at 16:24
  • Sorry I am bit late in updating the result of implementation. I was able to successfully complete this implementation in SearchProcessItem pipeline. 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.@Michael thanks for the great suggestion. Apr 8, 2023 at 7:59
0

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.

Your Answer

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

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