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.

How to: Specify a Content Source using the Keyword Syntax

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

 

Paul said:

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>";

November 27, 2009 8:12 AM
 

CoreyRoth said:

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\"";

November 27, 2009 11:40 AM

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