Specifying Scope(s) with the KeywordQuery class
Posted
Monday, March 10, 2008 2:22 PM
by
CoreyRoth
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.