It was just a question of time, sooner than later we would get a request to hide content in Microsoft Search.
"But why not just use permissions to ensure that only the right group of people can see the content", I hear you say?
Well, in this case the content is visible for everybody, but the business rule is that the content MUST be reviewed at a set interval, and if the content has not been reviewed within this deadline, the end user should not see the content in search anymore.
One option could be to have a workflow that breaks the permissions on the item level once the deadline has been reached, but that option comes with a certain smell of substandard performance and complexity.
The Microsoft Search approach looked less intrusive and gave me some options:
Option A)
I could add a Result Type in the Search and Intelligence Admin center that would "intercept" all items of the specific type (using Content type id or similar property) and only display those items that have been reviewed using the $when clause.
Option B)
I could change the query for the verticals in order to exclude specific content using a subset of KQL (Manage search verticals)
Initially I selected Option A, and use the Search Layout Designer to define the layout, but when the layout was used in the Result Type it had a hard time deciding if the date of the deadline is in the past or the future.
Both blocks below were displayed...but only in the Result Type, in the Search Layout Designer it worked as expected. 😕
Due to this issue, I investigated Option B.
Step one was to get the query right, and using Graph Explorer this was pretty easy:
When I tried to negate the query I found that using the - sign as a shorthand for NOT seems to be a no-go going forward.
Once that query works I just updated the Query for the relevant verticals, in this case only the All vertical.
Add "cacheClear=true" to your URL when testing the update as per Manage search verticals
Can this approach scale?
For now, this solution does solve the current problem, but I doubt very much that it can scale as additional content needs to be excluded.
It will be interesting to see the solution patterns that will be developed in the coming months as Microsoft Search becomes more top of mind in the MS365 world.
Comments