Paul Galvin's (old) SharePoint space [SharePoint

Just another site

FAST SharePoint Integration: Execute a Simple Query

This is a continuation in my FAST coding mini-series for SharePoint folk.  The bit of code below executes a search for the term "test" in FAST via a Console application.  Obviously, it’s a hop, skip and jump away to wrap this logic inside a web part or application page:


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.Specialized;
using Com.FastSearch.Esp.Search;
using Com.FastSearch.Esp.Search.Http;
using Com.FastSearch.Esp.Search.Navigation;
using Com.FastSearch.Esp.Search.Query;
using Com.FastSearch.Esp.Search.Result;
using Com.FastSearch.Esp.Search.View;
using System.Collections;

namespace Conchango
    class InvokeSimpleFASTQuery
        static void Main(string[] args)

            #region Initialize our communication with FAST
            ISearchFactory searchFactory;

            NameValueCollection nameValueCollection = new NameValueCollection();

            nameValueCollection.Add("fastsearchengine", "Com.FastSearch.Esp.Search.Http.HttpSearchFactory");
            nameValueCollection.Add("Com.FastSearch.Esp.Search.Http.QRServers", "fastdemoback:15100");
            nameValueCollection.Add("Com.FastSearch.Esp.Search.Http.RequestMethod", "GET");

            searchFactory = SearchFactory.NewInstance(nameValueCollection);


            #region Launch a query 
            string queryString = "test";

            Query query = new Query(queryString);

            query.SetParameter(BaseParameter.CLUSTERING, false);
            query.SetParameter(BaseParameter.NAVIGATION, true);
            query.SetParameter(BaseParameter.NAVIGATION_DEEPHITS, 100);

            ISearchView searchView;
            searchView = searchFactory.GetSearchView("sharepointconn");

            IQueryResult result = searchView.Search(query);

            Console.WriteLine("Total results from search: [" + result.DocCount + "].");

            int docCounter = 0;

            while (docCounter < result.DocCount)


                IDocumentSummary thisDocSummary = result.GetDocument(docCounter);

                Console.WriteLine("[" + docCounter + "]: " + thisDocSummary.GetSummaryField("url").StringValue);

            } // while



It generates the following result:


Subscribe to my blog.

Technorati Tags: ,

2 responses to “FAST SharePoint Integration: Execute a Simple Query

  1. Unknown February 24, 2009 at 12:52 am

    Got a quick question for you, Paul. I\’ve been trying to find out how to create these search views as it keeps returning 0 for GetSearchViewList().Count. Can you point me in the right direction?Thanks,Alvin

  2. Paul March 18, 2009 at 10:31 am

    Alvin, you probably figured this out already, but here goes…I don\’t know the answer, but I recall that I was getting zero views because something was wrong in terms of my server port config and that sort of thing. It\’s very picky.

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s

%d bloggers like this: