0

我正在使用 KeywordQuery 进行搜索并且.. SortList 不会影响结果,它总是返回前 5 个结果。有什么建议吗?代码如下...

    using (KeywordQuery query = new KeywordQuery(site))
                {
                            var fedManager = new FederationManager(application);
                            var owner = new SearchObjectOwner(SearchObjectLevel.SPSite, site.RootWeb);

                            query.SourceId = fedManager.GetSourceByName("NewsRS", owner).Id;
                            query.QueryText = string.Format("WorkflowStatusOWSCHCS:Approved PublishedUntilDate>=\"{0}\" OR NewsNewsPublishedDate<=\"{0}\"", DateTime.Now);
                            query.KeywordInclusion = KeywordInclusion.AllKeywords;
                            query.RowLimit = 5;
                            query.StartRow = 1;
                            query.SelectProperties.Add("NewsFriendlyUrl");
                            query.SelectProperties.Add("NewsNewsTeaser");
                            query.SelectProperties.Add("NewsNewsDate");
                            query.SelectProperties.Add("NewsPublishedUntilDate");
                            query.SelectProperties.Add("NewsNewsContent");
                            query.SelectProperties.Add("NewsNewsPublishedDate");
                            query.SelectProperties.Add("NewsNewsImage");
                            query.SortList.Add("NewsNewsDate", SortDirection.Descending);
                            var searchExecutor = new SearchExecutor();
                            var myResults = searchExecutor.ExecuteQuery(query);
}
}   

... NewsNewsDate 被标记为可排序

4

1 回答 1

0

查询.RowLimit = 5; => 您明确将 Rowlimit 指定为 5。这就是它始终返回前 5 个结果的原因。更改行限制并将其设置为您需要的结果数。

于 2014-08-22T17:40:09.840 回答