如何更新以下CSOM搜索代码以将搜索范围限制在SharePoint租户中的单个网站:
KeywordQuery keywordQuery = new KeywordQuery(spClientContext);
keywordQuery.QueryText = term;
keywordQuery.StartRow = page;
keywordQuery.RowLimit = pageSize;
keywordQuery.EnableStemming = true;
keywordQuery.TrimDuplicates = false;
SearchExecutor searchExecutor = new SearchExecutor(spClientContext);
ClientResult<ResultTableCollection> resultTableCollection = searchExecutor.ExecuteQuery(keywordQuery);
spClientContext.ExecuteQuery();
目前,它会从所有网站返回结果。使用CSOM MS SP Client v4.0.30319。谢谢你的帮助!
您可以在QueryText中添加路径管理的属性以在特定站点中进行搜索。例如:
keywordQuery.QueryText = "test path:https://tenant.sharepoint.com/sites/test";