ManagedProperty.Weight プロパティ (Microsoft.Office.Server.Search.Administration)
管理プロパティの重みの設定を取得または設定します。
名前空間: Microsoft.Office.Server.Search.Administration
アセンブリ: Microsoft.Office.Server.Search (microsoft.office.server.search.dll 内)
構文
'宣言
Public Property Weight As Single
'使用
Dim instance As ManagedProperty
Dim value As Single
value = instance.Weight
instance.Weight = value
public float Weight { get; set; }
プロパティ値
検索スキーマの管理プロパティの重みの値を指定する倍精度浮動小数点数。
備考
重みの設定は関連性フレームワークに適用され、ランク付けの計算を実行する場合の管理プロパティの相対的な重要度に影響します。
エンタープライズ検索 の関連性に関する詳細は、「エンタープライズ検索の関連性アーキテクチャの概要」および「関連性の向上」を参照してください。
例
以下のコード例は、管理プロパティの重みの設定を変更します。このサンプル コードを実行する完全な手順については、「[方法] 管理プロパティの重み設定を変更する」を参照してください。
Prerequisites
共有サービス プロバイダが既に作成されていることを確認します。
Project References
このサンプルを実行する前に、コンソール アプリケーション コード プロジェクトに以下のプロジェクト参照を追加します。
Microsoft.SharePoint
Microsoft.Office.Server
Microsoft.Office.Server.Search
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SharePoint;
using Microsoft.Office.Server.Search.Administration;
namespace PropertyWeightSample
{
class Program
{
static void Main(string[] args)
{
try
{
if (args.Length != 2)
{
Usage();
return;
}
/*
Replace <SiteName> with the name of a site using the Shared Service Provider.
*/
string strURL = "http://<SiteName>";
Schema sspSchema = new Schema(SearchContext.GetContext(new SPSite(strURL)));
ManagedPropertyCollection properties = sspSchema.AllManagedProperties;
string strPropertyName = args[0].ToLower();
float newWeight = Convert.ToSingle(args[1]);
if (!properties.Contains(strPropertyName))
{
Console.WriteLine(strPropertyName + " property does not exist.");
return;
}
foreach (ManagedProperty property in properties)
{
if (property.Name.ToLower() == strPropertyName)
{
property.Weight = newWeight;
Console.WriteLine("Weight value changed for " + strPropertyName + " property.");
Console.WriteLine("NAME: " + property.Name + " WEIGHT: " + property.Weight.ToString());
}
}
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
Usage();
}
}
private static void Usage()
{
Console.WriteLine("Change Property Weight");
Console.WriteLine("Usage: PropertyWeightSample.exe ManagedPropertyName <WeightValue>");
Console.WriteLine("<WeightValue>: Must be formatted as a float.");
}
}
}
関連項目
参照
ManagedProperty クラス
ManagedProperty メンバ
Microsoft.Office.Server.Search.Administration 名前空間