May 25 / Michiel

FullTextSqlQuery Exception from HRESULT: 0x80040E60

After upgrading a webpart from SharePoint 2007 to 2010 I got a exception from de search engine about the query format. I used the following code:

var sqlQuery = new FullTextSqlQuery(SPContext.Current.Site);
sqlQuery.ResultTypes = ResultType.RelevantResults;
sqlQuery.TrimDuplicates = false;
sqlQuery.QueryText = "SELECT Path, Title FROM scope() ORDER BY Title";

// Return the search results to a ResultTableCollection.
var results = sqlQuery.Execute();

When I debugged the code I found out that the ORDER BY clause was causing the problem. When I used a integer or date managed property in the order by clause the problem disappeared. I started investigating the options for text managed properties, in the properties for a managed property I found a new option:

image

The explanation for this option is:

To reduce storage requirements, new text properties are automatically treated as a hash which limits comparisons (including sorting) to equality/inequality.  Unselect this option to enable other types of comparisons (less than, greater than, order by).

When I enabled this option and started a full-crawl the problems are gone. In my opinion the error message should have been a bit more clearer.

Leave a Comment