SharePoint Online-通过CSOM获取托管属性

问题描述

https://.sharepoint.com具有数百个网站集,每个网站集有多个网站,并且每个网站都没有用于存储文档的库。每个库都有一个自定义的托管属性,并在SharePoint-Online中设置为自定义托管属性-我称其为ManagedProperty。有时在列表项的标题和内容中使用ManagedProperty的值。 KeywordQuery搜索带来列表项,其中ManagedProperty值是标题的一部分,而不是ManagedProperty字段值。我决定与ManagedProperty值一起获取列表项,以通过以下CSOM代码进行过滤。

问题:以下代码的搜索结果有两种情况:

  1. result.Value [0] .ResultRows将ManagedPropertyName设置为null,并将ManagedPropertyOWSTEXT(对应的爬网属性ows_q_TEXT_ManagedPropertyName)设置为某些网站集下的所需值。
  2. result.Value [0] .ResultRows将ManagedPropertyOWSTEXT设置为null,并将ManagedPropertyName设置为其他网站集的所需值。

在两种情况下,ManagedProperty值都设置为SharePoint中的搜索值。如何在SharePoint中设置ManagedProperty字段时使ManagedPropertyName始终具有值?

var propertyValue = "123456";
        using (var context = new ClientContext("https://<company>.sharepoint.com/"))
        {                
            SPSecurityProvider.Context = context;
            SPSecurityProvider.ConfigureSecureAccess();

            var query = new KeywordQuery(context);
            query.QueryText = propertyValue;
            query.ClientType = "CSOM";
            query.SelectProperties.Add("ManagedPropertyName");
            query.SelectProperties.Add("ManagedPropertyOWSTEXT");

            SearchExecutor search = new SearchExecutor(context);
            ClientResult<ResultTableCollection> result = search.ExecuteQuery(query);
            context.ExecuteQuery();
            
            var resultR = result.Value[0].ResultRows.FirstOrDefault();
        }

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)