I'm writing a custom search app. Currently using the KeywordQuery class. I can get results fine, but if I try to sort by a custom property, it bombs with:
Can't sort by pid 400 for one or more of the following reasons: multi-valued: false, binary: false, non-indexed: true.
The following is the code. Anyone spot the issue? If i sort by "Rank" it'll work fine, but not if I use a manged property.
KeywordQuery query = new KeywordQuery(proxy);
query.IgnoreAllNoiseQuery = false;
query.ResultsProvider = Microsoft.Office.Server.Search.Query.SearchProvider.Default;
//Return following properties
query.SelectProperties.Add("Title");
query.SelectProperties.Add("Path");
query.SelectProperties.Add("SiteDescription");
query.SelectProperties.Add("SiteKeywords"); //This is a multi-value so will have to be parsed
query.SelectProperties.Add("SiteType");
query.SelectProperties.Add("ContentClass");
query.SelectProperties.Add("SiteName");
//Query text (WHERE)
query.QueryText = queryText;
//Sort
//Not sure what the criteria is here, but trying to sort by Title does not work. ULS indicated it may need to be an indexed column?
query.SortList.Add("Title", Microsoft.Office.Server.Search.Query.SortDirection.Descending);
query.ResultTypes |= ResultType.RelevantResults;
ResultTableCollection searchResults = query.Execute();