How can I preconfigure which refiners appear in a search results refinement web part?
-
29-09-2020 - |
Question
I'm developing a custom search solution for a client with a requirement to automatically deploy some search results pages with refinement panels whenever a new sub site is created. I'm doing this with a feature which adds the result pages to the new site and places a ResultScriptWebPart and a RefinementScriptWebPart on each page.
What I need to do now is set the RefinementScriptWebPart to use the correct custom refiners (the refiners are already created) but I can't find a property or a setting to allow me to do this.
The only thing that looks like it might be useful is the SelectedRefinementControlsJson property but I can't find any documentation for it.
Does anyone know whether it's possible to configure the refiners by altering SelectedRefinementControlsJson and what properties need to be set, or indeed if there's a better way of approaching it altogether?
Solution
It looks like you are on the right track with the SelectedRefinementControlsJson propety. If you pre-configure and export a refinement webpart you can see how it populates the refiners. Here is a default export example.
<property name="SelectedRefinementControlsJson" type="string">
{"refinerConfigurations":[{"propertyName":"FileType","displayName":null,"displayTemplate":"~sitecollection/_catalogs/masterpage/Display Templates/Filters/Filter_Default.js","maxNumberRefinementOptions":21,"type":"Text","refinerSpecStringOverride":null,"useDefaultDateIntervals":false,"isInherited":false,"sortBy":0,"sortOrder":0,"intervals":null,"aliases":null},{"propertyName":"contentclass","displayName":null,"displayTemplate":"~sitecollection/_catalogs/masterpage/Display Templates/Filters/Filter_Default.js","maxNumberRefinementOptions":10,"type":"Text","refinerSpecStringOverride":null,"useDefaultDateIntervals":false,"isInherited":false,"sortBy":0,"sortOrder":0,"intervals":null,"aliases":null},{"propertyName":"ContentTypeId","displayName":null,"displayTemplate":"~sitecollection/_catalogs/masterpage/Display Templates/Filters/Filter_Default.js","maxNumberRefinementOptions":15,"type":"Text","refinerSpecStringOverride":null,"useDefaultDateIntervals":false,"isInherited":false,"sortBy":0,"sortOrder":0,"intervals":null,"aliases":null},{"propertyName":"WebTemplate","displayName":null,"displayTemplate":"~sitecollection/_catalogs/masterpage/Display Templates/Filters/Filter_Default.js","maxNumberRefinementOptions":10,"type":"Text","refinerSpecStringOverride":null,"useDefaultDateIntervals":false,"isInherited":false,"sortBy":0,"sortOrder":0,"intervals":null,"aliases":null},{"propertyName":"DisplayAuthor","displayName":null,"displayTemplate":"~sitecollection/_catalogs/masterpage/Display Templates/Filters/Filter_Default.js","maxNumberRefinementOptions":9,"type":"Text","refinerSpecStringOverride":null,"useDefaultDateIntervals":false,"isInherited":false,"sortBy":0,"sortOrder":0,"intervals":null,"aliases":null},{"propertyName":"LastModifiedTime","displayName":null,"displayTemplate":"~sitecollection/_catalogs/masterpage/Display Templates/Filters/Filter_SliderBarGraph.js","maxNumberRefinementOptions":0,"type":"DateTime","refinerSpecStringOverride":null,"useDefaultDateIntervals":true,"isInherited":false,"sortBy":0,"sortOrder":0,"intervals":null,"aliases":null}]}
</property>