Special Characters in RefinementFilter

Posted by & filed under .

When attempting to use a refiner with values containing special characters (hyphen, dash, backslash, etc) you’ll run into an issue where the refinementfilters=’property:equals(“value-name”)’ doesn’t return any results (despite the refiner indicating that it has results matching this value). There is a technet discussion around this issue, but the suggested resolution loses the precision of the “:equals” matching, which isn’t ideal.

However there is hope! If you perform the refinement with multiple values for the property, using the syntax refinementfilters=’property:or(“value-name”,”other-value-name”)’, the results are returned as expected. But that’s only useful if you have multiple refiners selected.

My proposed workaround? Add some code that detects if there is only a single refiner, and add a dummy refiner as the second item to refine against.

refinementfilters=’property:or(“value-name”,”DummyValueNeverMatch_WorkaroundForSpecialCharacterRefinerIssue”)’

That name should hopefully indicate to anyone who examines it why it’s there.