我有一个单词(docx)文档存储在OneDrive for business上。它的结构如下:
<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();
}
但它不起作用。它只返回单词标题和作者。我做错了什么?
答案 0 :(得分:0)
语法应遵循关键字查询语言规范(您正在使用KeywordQuery
)
Keyword Query Language (KQL) syntax reference
对于你的要求你应该使用像
这样的东西query.QueryText = "Author:John AND Title:Test*";