2012-01-19 7 views
1

私は自分のコンテンツソースでSharepoint Searchを開発しています。そして、私は自分のクロール・プロパティーとマネージド・プロパティーを持ち、それに応じてマッピングします。 また、私は動的プロパティを持っています。ユーザーはプロパティのセットをクロールするように変更できます。したがって、実行時にSharepoint Central Administrationから作成します。私はそれを行うには、次のコードを使用してい :CrawlPropertyを "インデックスに含める"値をプログラムで設定します(Sharepoint 2007)

private static void CreateProperty(string propertyName, Category category, ManagedPropertyCollection managedProperties) 
    { 
     var crawledProperty = category.CreateCrawledProperty(propertyName, false, Constants.CategoryId, 31); 
     crawledProperty.IsMappedToContents = true; 
     SetMapping(crawledProperty, managedProperties); 
     crawledProperty.Update(); 
    } 

    private static void SetMapping(CrawledProperty cProp, ManagedPropertyCollection managedProperties) 
    { 
     ManagedProperty mProp = managedProperties.Create(cProp.Name, ManagedDataType.Text); 
     mProp.EnabledForScoping = true; 
     Mapping newMapping = new Mapping(cProp.Propset, cProp.Name, cProp.VariantType, mProp.PID); 
     MappingCollection mappings = mProp.GetMappings(); 
     mappings.Add(newMapping); 
     mProp.SetMappings(mappings); 
     mProp.EnabledForScoping = true; 
    } 

を静的プロパティは、インストールしながら、追加、動的プロパティは、サーバーの全体管理でてmanualy追加されます。 セントラル管理でインストールと設定の際に同じコードを使用してプロパティを追加しています。

問題は、クロールプロパティのSharepointフラグ "Included in index"の値です。この場合、インストールが完了すると、このフラグの値はすべての静的クロールプロパティでTRUE(yes)になります。それ以外の場合、動的プロパティの場合、このフラグはFALSE(いいえ)です。私はいつもフラグ "Included in index"をチェックしておく必要があります。

私が知っているように、CrawlPropertyクラスのIsMappedToContentsプロパティは「Included to index」値に応答しますが、それは私のためには機能しません!

あなたはそれを行うことをお考えですか?そして私は間違って何をしているのですか?

ありがとうございます。

答えて

2

この問題が見つかりました。それはSharepointの愚かなトリックです! 主な問題は、sharepointにオブジェクトインスタンスのキャッシュがあることです。 この記事では、クロールプロパティIsMappedToContentsのプロパティ値をプログラムによって更新する方法のサンプルを書きました。

foreach (CrawledProperty crawledProperty in category.GetAllCrawledProperties()) 
{ 
    crawledProperty.IsMappedToContents = true; 
    crawledProperty.Update(); 
} 

変数crawledPropertyの新しいインスタンスを使用する必要があります。あなたがこのようなものを書くなら、

CrawledProperty crawledProperty = category.CreateCrawledProperty(...); 
crawledProperty.IsMappedToContents = true; 
crawledProperty.Update(); 

あなたは失敗しました!

したがって、は、常にこのプロパティを変更するためにcategory.GetAllCrawledProperties()クロールされたプロパティのインスタンスを使用します。

PS:IsMappedToContentsは、Sharepointの「インデックスに含まれる」チェックボックスに対応しています。 * PS2:この資料は、Sharepoint 2010にはキャッシュインスタンスと同様の問題がないことを知っているので、Sharepoint 2007で動作します。 *

関連する問題