FAST Search for SharePoint : Query API

Hello again ūüôā

We all have to agree that search plays an integral part of any successful SharePoint deployment and is an area that Microsoft continues to invest in with each new release of SharePoint.

In this exercise, you will build a .NET console application to submit a query to FAST Search and parse the resulting dataset.

First of all we are going to Retrieve results from FAST Search using the Web Service search.asmx and then we are going to display them on the console.

So lets Get Started ūüėČ

1. we are going to test the Web Service so open your browser and type your server name /_vti_bin/search.asmx

and to take a look at the WSDL file of the WebService click on Service Description

you can also have more informations on the methods displayed by clicking on them.

2. lets move on to our project !! First of all create a console project in Visual studio 2010 named TestSearch

3. Then we are going to reference the WebService.

4. put this data in the form


Namespace: QueryService

Your Service Reference should look like this. OK to save your changes.

Wait for the Service Reference to create.

Ensure the new Service Reference is listed in the Solution Explorer pane.

5. Edit the app.config file.

6. Build your application:

7. Edit the program.cs file.

a. Add this code to the Main method.

b. then add this security code to check for Windows credentials. These methods require System.Net.

client.ClientCredentials.Windows.ClientCredential = CredentialCache.DefaultNetworkCredentials;

client.ClientCredentials.Windows.AllowedImpersonationLevel =     System.Security.Principal.TokenImpersonationLevel.Impersonation;

c. then add the Query:

e. finally Execute a search using QueryEx.

System.Data.DataSet dataset = client.QueryEx(queryXML);

f. and Retrieve the TotalRows, Title, Rank, Size, and HitHightlightedSummary from the relevantresults datatable.

string totalRows = dataset.Tables[“relevantresults”].ExtendedProperties[“TotalRows”].ToString();

Console.WriteLine(“Total Results:” + totalRows);

int itotalRows = Convert.ToInt32(totalRows);

for (int i = 0; ((i < 10) && (i < itotalRows)); i++)


Console.WriteLine(“Rank: ” + dataset.Tables[“relevantresults”].Rows[i][“Rank”].ToString());

Console.WriteLine(“Title: ” + dataset.Tables[“relevantresults”].Rows[i][“Title”].ToString());

Console.WriteLine(“Size: ” + dataset.Tables[“relevantresults”].Rows[i][“Size”].ToString());

Console.WriteLine(“Summary: ” + dataset.Tables[“relevantresults”].Rows[i][“HitHighlightedSummary”].ToString());



and here is the result ūüôā


One thought on “FAST Search for SharePoint : Query API

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s