in

Dot Net Mafia

Group site for developer blogs dealing with (usually) .NET, SharePoint 2013, SharePoint 2010, Office 365, SharePoint Online, and other Microsoft products, as well as some discussion of general programming related concepts.

This Blog

Syndication

Archives

Corey Roth [MVP]

A SharePoint MVP bringing you the latest time saving tips for SharePoint 2013, SharePoint 2010, Office 365, SharePoint Online, MOSS 2007, ASP.NET, LINQ, and Visual Studio 2012.

Specifying Scope(s) with the KeywordQuery class

Today I realized that when I blogged about how to use the KeywordQuery class, I forgot to mention how to specify the scope(s) you are querying.  You would think there would be a built-in property to set this, but there isn't.  I wanted to see how Microsoft was doing it so I used reflector and examined the notorious SearchResultsHiddenObject that the CoreResultsWebPart uses.  It in fact does what I expected.  It simply iterates through the list of scopes and appends each one to the keyword query string (i.e.: Scope:"Working Documents").  I was hoping there would be a more elegant way of doing this, but this appears to be the way.

Comments

No Comments

Leave a Comment

(required)  
(optional)
(required)  
Add

About CoreyRoth

Corey Roth is an Applications Architect at Infusion specializing in ECM and Search.
2012 dotnetmafia.
Powered by Community Server (Non-Commercial Edition), by Telligent Systems