The provided scripts support filtering on:
- a search term
- multiple refiners
- multiple values for a refiner, or
- any combination of the above
It would be worth reading the intro of my earlier article to get a better understanding of what is happening in the snippets provided in this post.
- As the most common usage will surely be to produce search result page URLs that are refined on a single value, I have written an ‘overload’ function that simplifies calling the method in this scenario
- The ‘search page URL’ can be provided to the functions in a number of ways including:
- “/search” : to the web. The default page for that web. In the case of an Enterprise Search Centre this will be the ‘Everything’ search results page
- “/search/Pages/peopleresults.aspx” : to the page
- Use an absolute URL if you are out of the context of the SharePoint Online tenant in which the search page resides. This will be true for provider hosted add-ins (apps)
- If you are writing your own refiner, then pass an empty string and set
window.location.hashto the result of the function
- This script has no dependencies on other libraries (jQuery, SP.js, etc)
- I took inspiration for the stringToHex method from a post by pussard
These are examples of how to call the function that are defined above.