•
FAST Search in SharePoint
Document sharing is a key benefit of SharePoint. But what good is this feature if you can’t find the document you are looking for? Fortunately, another benefit of SharePoint is the ability to utilize FAST Search.
The key advantages of FAST over out of box SharePoint search that I want to highlight are refinement and sorting.
Enabling the Deep Refiner property on any managed property allows you to drill down on specific attributes associated with a document. This is very useful when you know exactly what you are searching for.
Enabling the Sort property on any managed property does exactly what you would think it would do, indicates whether this property will be sortable or not.
An example of a simple search query to find all documents in which the Company is RefineCo would be:
Company:"RefineCo"
And an example of a more complex search query to find all documents in which Company is RefineCo and Author is John Doe would be:
and(Company:"RefineCo", Author:"John Doe")
(There are certain keywords reserved in FQL that you can see here: FAST Query Language (FQL) syntax reference)
Code Example:
[code language=”csharp”]SearchServiceApplicationProxy proxy = (SearchServiceApplicationProxy)SearchServiceApplicationProxy.GetProxy(SPServiceContext.GetContext(this.Web.Site));
KeywordQuery query = new KeywordQuery(proxy);
query.ResultsProvider = Microsoft.Office.Server.Search.Query.SearchProvider.Default;
query.QueryText = "company:refineco";
query.ResultTypes |= ResultType.RelevantResults;
query.TrimDuplicates = false;
query.EnableStemming = true;
query.EnableFQL = true;
query.SortList.Add("company", SortDirection.Ascending);
query.Execute();[/code]
One quirk with KeywordQuery and FAST is ensuring that the KeywordQuery.QueryText is in lowercase. Otherwise, you will likely get a “Property doesn’t exist or is used in a manner inconsistent with schema settings” error.
Similarly, when adding managed properties to the KeywordQuery.SortList, they too need to be in lowercase. However, unlike with KeywordQuery.QueryText throwing an exception if it is not in lowercase, SortList will just simply not sort the results. Thus, making you think that sorting is broken and hacking together your own sort functionality after the search executes, which I regretfully did. All credit for solving this goes to Shaun.