I’ve been doing a bit of work with the KeywordQuery object in SharePoint 2010 and making use of the HiddenConstraints property.
I didn’t find any immediately helpful information on the that property, so I thought I’d quickly jot down how I’ve been using it.
As far as I can tell, this is an automatic constraint added to the query so that you can sort of park it there and not worry about it. As such, it’s just another keyword (or set of keywords) and modifiers that you can type in to the UI when you do a keyword search. Here’s an example:
keywordQuery.HiddenConstraints = "scope:\"Industry\"";
You can add additional constraints with a space delimiter.
keywordQuery.HiddenConstraints = "scope:\"Industry\" defense";
The above is saying in English, “run a keyword query looking for “defense” and furthermore, use the “Industry” scope.
Here’s another way of looking at it:
I’ve been using it to provide a context-dependent automatic scope on a custom web part. When the user clicks on a tab and clicks a search button, the tab dictates a particular search scope. It’s working well so far.
</end>
Follow me on Twitter at http://www.twitter.com/pagalvin