FAST SharePoint Integration: Sample Code to Display All Available FAST Views

 

Here is some code that shows all available views from a FAST server based on the named QRServer (the server process with which we communicate).  I offer this up to give you all a taste of what it’s like to use the provided FAST API.

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
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.Specialized;
using System.Collections;


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

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

            Console.WriteLine("Total Views: [" + searchFactory.GetSearchViewList().Count + "].");

            int i = 0;

            foreach (object o in searchFactory.GetSearchViewList())
            {
                Console.WriteLine("View [" + i++ + "]: [" + o.ToString() + "].");

            }

            Console.ReadLine();

        }
    }
}

 

Note that I consider myself a barely competent C# programmer and I have thin skin, so don’t send any raspberries my way, especially re: the "foreach (object o in …)" construct 🙂

</end>

Technorati Tags: ,

Subscribe to my blog.

Leave a Reply

Your email address will not be published. Required fields are marked *