This project is read-only.

Project Description
This project implements a federated location for SharePoint 2010, that allows you to search listitems in your site collection using the standard search API.

Motivation/Goal

Currently there exists two primary methods to query SharePoint content; the Core Results Web Part and the Content Query Web Part. The Core Results Web Part looks into the search index and can search data across site collection bounderies, but the data need to be crawled before its indexed, hence you will have a latency on updates.

The Content Query Web Part uses CAML to search data and will have more "fresh" data than the Core Results Web Part, but the Content Query Web Part is limited to the site collection bounderies.

This federated location brings "fresh" data into the Core Results Web Part using federation and CAML as the search mechanism. That way you will only have one uniform way to search and visualize data.

Architecture

The standard keyword query synxtax is used as the query language, this is parsed into an expression tree and then translated into a CAML query:

The items returned from the query is then returned as in the standard <All_Results><Result> format.

Usage, Programmaticly

using (var site = new SPSite("http://sharepoint"))
{
    var serviceContext = SPServiceContext.GetContext(site);

    var searchProxy = (SearchServiceApplicationProxy)serviceContext.GetDefaultProxy(typeof(SearchServiceApplicationProxy));

    var properties = new StringCollection { "title", "path", "author", "sitetitle", "size", "description", "write" };

    const int startItem = 1;

    var queryManager = new QueryManager();
    var locationList =
        new LocationList
            {
                new Location("SiteSearch", searchProxy)
                    {
                        RequestedProperties = properties,
                        StartItem = startItem,
                        ItemsPerPage = 20, 
                        TrimDuplicates = false
                    }
            };


    queryManager.UserQuery = "site:\"http://sharepoint/\" contenttype:\"Welcome Page\"";
    queryManager.Add(locationList);
    queryManager.IsTriggered(locationList);

    var xmlDocument = queryManager.GetResults(locationList);

    // Use xmlDocument
}

 

Usage, Core Results WebPart
Change location to "Local Site Search Results":

Last edited Feb 11, 2012 at 6:59 PM by allanhvam, version 21