So here is my first blog post that is more of a light bulb moment vs. a deeply brooded and though out post that I would like to think that I am known for. I have to say I feel pretty good about it. So lets dive right in.
Scenario: I was requested by the client to build custom scopes to allow for targeted search pages per department. Some of the defining information was in the Term Store in which we would use to filter the information targeting the specific department. (All names and other identifying information has been altered to protect the innocent.) In the term store were the names of the different departments. One department name was R2-D2. Simple, straight forward to create a scope specific to our department. Below is the Query Text.
{searchTerms} Path:”https://starwarsCharacters.com/Lists/Site%20Directory/*” contentclass:STS_ListItem DeathstarDivision=”R2-D2″ |
It works like a charm for other departments, but this one… the one with the “-“ returned zero results… none! Whaaa? Working with my colleague, Mark Candelora, we tried different variations. The result is what surprised me. I should have known it, but sometimes the simplest things will trip us up.
The Findings: When the indexer runs it treats both the dash “-“ and the underscore “_” as a space. When the scopes are created, they are created off of the indexed information. This includes terms in the term store. The answer to fix the conundrum I was dealing with is with nothing more than a space instead of dash. As soon as I changed the scope Query Text to the following. Everything got lit up like the fourth of July. Good times!
{searchTerms} Path:”https://starwarsCharacters.com/Lists/Site%20Directory/*” contentclass:STS_ListItem DeathstarDivision=”R2 D2″ |
Of course then again what is R2-D2 without the “-“? Call signs for a very large game of Battleship I guess…