オブジェクト コード モデルを使用して、sharepoint 検索から検索結果を取得しています。検索に高度な検索オプションを設定する方法を提案できますか。オブジェクト コード モデルには、高度な検索を実行する機能がありますか。
1757 次
1 に答える
1
はい、以下のコード例に示すように、 FullTextSqlQueryクラスを使用して高度な検索を実行できます。ベスト プラクティス: エンタープライズ サーチで関連する結果を得るための SQL 構文クエリの作成も参照してください。
using (SPSite site = new SPSite("http://server")) // Site Collection URL
using (FullTextSqlQuery query = new FullTextSqlQuery(site))
{
query.ResultTypes = ResultType.RelevantResults;
query.EnableStemming = true;
query.TrimDuplicates = true;
query.Culture = new CultureInfo(1033); // Use en-US stemmer and word-breaker
query.RowLimit = 40;
query.StartRow = 0;
query.KeywordInclusion = KeywordInclusion.Allkeywords; // Implicit AND search
query.HighlightedSentenceCount = 3;
query.SiteContext = new Uri("http://server"); // Site Collection URL
query.QueryText = "SELECT WorkId, Title, Path, HitHighlightedSummary, HitHighlightedProperties, CollapsingStatus, Description, Rank, Size" +
" FROM SCOPE()" +
" WHERE \"scope\" = 'A Scope'" +
" AND FREETEXT(defaultproperties, 'keyword1 keyword2')" +
" AND Color = 'Black'" + // Color is a managed property
" ORDER BY Rank DESC";
ResultTableCollection results = query.Execute();
ResultTable relevantResults = results[ResultType.RelevantResults];
// TODO: Process results
};
于 2009-03-13T10:48:36.910 に答える