How to: Specify a Content Source using the Keyword Syntax

Posted Tuesday, March 11, 2008 1:18 PM by CoreyRoth

At some point you may want to do an Enterprise Search query and specify that the results come from a particular content source.  A lot of times you might create a custom scope with that content source in it, but if you don't want to create a new scope, you can just query the content source directly.  The syntax is simple.  Just use it like in the example below.

ContentSource:"Local Office SharePoint Sites"

In this case, I want everything to come from the Local Office SharePoint Sites content source.  You can of course combine it with other terms as well like in the example below.

Bike Color:"Red" ContentSource:"BDC AdventureWorks"

In this case, it would search for red bikes in the BDC AdventureWorks content source.  Kind of a simple tip today, but I really haven't seen this documented anywhere.

Comments

# re: How to: Specify a Content Source using the Keyword Syntax

Friday, November 27, 2009 8:12 AM by Paul

how can I add scope if I am just passing keywords to the search web service?

string qXMLString = "<QueryPacket xmlns='urn:Microsoft.Search.Query'>" +

           "<Query><SupportedFormats><Format revision='3'>" +

           "urn:Microsoft.Search.Response.Document:Document</Format>" +

           "</SupportedFormats><Context><QueryText language='en-US' type='STRING'>" +

           Keywords + "</QueryText></Context><Range><Count>25</Count></Range></Query></QueryPacket>";

# re: How to: Specify a Content Source using the Keyword Syntax

Friday, November 27, 2009 11:40 AM by CoreyRoth

It's actually pretty simple.  I am assuming Keywords is a variable containing your query.  If so you can add it by doing something like this.

Keywords += "Scope:\"My Scope\"";

Leave a Comment

(required)
(required)
(optional)
(required)