Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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 everithing is working as I expect. But when I replace WorkEmail with say JobTitle sorting does not work. It works as if sort list passed to KeywordQuery is empty. My view is that something wrong with managed properties metadata. MaxCharactersInPropertyStoreIndex = 64 for both mentioned properties

share|improve this question

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.