SharePoint搜索查询
本文关键字:查询 搜索 SharePoint | 更新日期: 2023-09-27 18:18:14
我有一个word (docx)文档存储在OneDrive上用于业务。它的结构类似于:
<title>
Book Title
</title>
<author>
High
</author>
然后我用Microsoft.SharePoint.Client搜索标题和作者
var targetSite = new Uri("https://my-site.sharepoint.com");
var login = "login";
var password = "pass";
var securePassword = new SecureString();
foreach (char c in password)
{
securePassword.AppendChar(c);
}
var onlineCredentials = new SharePointOnlineCredentials(login, securePassword);
using (ClientContext clientContext = new ClientContext(targetSite))
{
clientContext.Credentials = onlineCredentials;
var query = new KeywordQuery(clientContext);
query.QueryText = "<title></title><author></author>";
var searchExecutor = new SearchExecutor(clientContext);
var result = searchExecutor.ExecuteQuery(query);
clientContext.ExecuteQuery();
}
但是它不起作用。它只返回单词标题和作者。我做错了什么?
语法应遵循关键字查询语言规范(您正在使用KeywordQuery
)
对于你的要求,你应该使用像
这样的东西query.QueryText = "Author:John AND Title:Test*";