views:

12

answers:

2

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();
A: 

If it's a managed property it needs to have the option "Reduce storage requirements for text properties by using a hash for comparison." checked.

Donaldinio
A: 

Hi Donaldinio

I'm currently facing the same issue. And I can confirm, that checking the option "Reduce storage requirements..." will let the exception disappear. But then the sorting is based on the hash and not the actual value of the field. So the results are not in the correct order. Can you confirm this? Or am I wrong?

Regards, Marc

Marc