tags:

views:

162

answers:

1

I am a sharepoint newbee and am having trouble getting any search results to return using the search API in Sharepoint 2010 Foundation.

Here are the steps I have taken so far.

  1. The Service Sharepoint Foundation Search v4 is running and logged in as Local Service
  2. Under Team Site - Site Settings - Search and Offline Availability, Indexing Site Content is enabled.
  3. Running the PowerShell script Get-SPSearchServiceInstance returns

TypeName : SharePoint Foundation Search
Description : Search index file on the search server
Id : 91e01ce1-016e-44e0-a938-035d37613b70
Server : SPServer Name=V-SP2010
Service : SPSearchService Name=SPSearch4
IndexLocation : C:\Program Files\Common Files\Microsoft Shared\Web Server Exten sions\14\Data\Applications
ProxyType : Default
Status : Online

  1. When I do a search using the search textbox on the team site I get a results as I would expect.

Now, when I try to duplicate the search results using the Search API I either receive an error or 0 results.

Here is some sample code:

using Microsoft.SharePoint.Search.Query;
using (var site = new SPSite(_sharepointUrl, token))
            {
                // 
                FullTextSqlQuery fullTextSqlQuery = new FullTextSqlQuery(site)
                {
                    QueryText = String.Format("SELECT Title, SiteName, Path FROM Scope() WHERE \"scope\"='All Sites' AND CONTAINS('\"{0}\"')", searchPhrase),
                    //QueryText = String.Format("SELECT Title, SiteName, Path FROM Scope()", searchPhrase),
                    TrimDuplicates = true,
                    StartRow = 0,
                    RowLimit = 200,
                    ResultTypes = ResultType.RelevantResults
                    //IgnoreAllNoiseQuery = false
                };

                ResultTableCollection resultTableCollection = fullTextSqlQuery.Execute();
                ResultTable result = resultTableCollection[ResultType.RelevantResults];

                DataTable tbl = new DataTable();
                tbl.Load(result, LoadOption.OverwriteChanges);
}

When the scope is set to All Sites I retrieve an error about the search scope not being available. Other search just return 0 results.

Any ideas about what I am doing wrong?

A: 

This is the workaround we came up with.

  1. We did not get the foundation search to work as we had hoped. We will review it again once the RTM version of Sharepoint Foundation is released.

  2. We installed Search Server Express 2010 beta. This allowed us to use the office server namespaces and the corresponding classes. This worked as expected and we were able to programmatically search against Sharepoint Foundation.

MB