SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Can anyone help me with SharePoint 2010 KeywordQuery problem? I have the following code to search user profile and sort results by managed property.

var keywordQuery = new KeywordQuery(site)
{
    QueryText = "",
    KeywordInclusion = KeywordInclusion.AllKeywords,
    HiddenConstraints = "scope:" + "\"People\"",
    ResultTypes = ResultType.RelevantResults,
    RankingModelId = "D9BFB1A1-9036-4627-83B2-BBD9983AC8A1"
};

keywordQuery.EnablePhonetic = true;
keywordQuery.EnableNicknames = true;
keywordQuery.ResultsProvider = SearchProvider.SharepointSearch;

keywordQuery.SortList.Add("WorkEmail", SortDirection.Ascending);

keywordQuery.SelectProperties.Add("PreferredName");
keywordQuery.SelectProperties.Add("AccountName");
keywordQuery.SelectProperties.Add("OrganizationDepartment");
keywordQuery.SelectProperties.Add("UserFirstName");
keywordQuery.SelectProperties.Add("UserLastName");
keywordQuery.SelectProperties.Add("UserSurName");

ResultTableCollection resultTableCol = keywordQuery.Execute();
ResultTable resultTable = resultTableCol[ResultType.RelevantResults];

When I use WorkEmail as the property to sort by everything is working as expected.

But when I replace WorkEmail with say JobTitle sorting does not work. It behaves as if the sort list passed to KeywordQuery is empty.

My view is that something wrong with managed properties metadata. MaxCharactersInPropertyStoreIndex is set to 64 for both mentioned properties.

share|improve this question

Bit of a delayed reply on this but this might help someone else - even with SharePoint 2013.

If you recently changed the MaxCharactersInPropertyStoreIndex property of a managed property you'll most likely have to do a full crawl of the content source before it will take effect and be sortable.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.