The SharePoint search service works on documents content and it Metadata (properties), I need to retrieve the field name and it content (SPField) which the search are matched on it.
What field should I add to the SelectProperties object ? or where I can find these information.
KeywordQuery keywordQuery = new KeywordQuery(SPContext.Current.Site);
keywordQuery.QueryText = queryText;
keywordQuery.ResultsProvider = SearchProvider.Default;
var selecProperties = keywordQuery.SelectProperties;
selecProperties.Add("UniqueId");
selecProperties.Add("FileLeafRef");
selecProperties.Add("ListId");
selecProperties.Add("WebId");
selecProperties.Add("Created");
selecProperties.Add("CheckoutUserOWSUSER");
SearchExecutor searchExecutor = new SearchExecutor();
ResultTableCollection resultTableCollection = searchExecutor.ExecuteQuery(keywordQuery);
ResultTable resultTable = resultTableCollection.Filter("TableType", KnownTableTypes.RelevantResults).FirstOrDefault();
DataTable dataTable = resultTable.Table;
我在属性HitHighlightedProperties
的KeywordQuery
对象中找到了解决方案,所有需要的就是将已爬网的属性(托管属性)添加到SelectProperties
和HitHighlightedProperties
,然后在该字段中,您将发现xml在所有可用字段中包含有关found关键字的详细信息。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.