1

次のコードで ComputedIndexFields.config ファイルを追加します。

<?xml version="1.0" encoding="utf-8" ?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
    <contentSearch>
      <configuration>
         <defaultIndexConfiguration>
          <fields hint="raw:AddComputedIndexField">
            <field fieldName="AppliedThemes" storageType="yes" indexType="TOKENIZED">be.extensions.AppliedThemes, be.extensions</field>
          </fields>
        </defaultIndexConfiguration>
      </configuration>
    </contentSearch>
  </sitecore>
</configuration>

上記のアセンブリにクラスも追加しました:

namespace be.extensions
{
    class AppliedThemes : IComputedIndexField
    {

        public string FieldName { get; set; }
        public string ReturnType { get; set; }

        public object ComputeFieldValue(IIndexable indexable)
        {
        Item item = indexable as SitecoreIndexableItem;
        if (item == null)
            return null;

        var themes = item["Themes"];
        if (themes == null)
            return null;

        // TODO
        }
    }
}

これは、計算されたインデックス フィールドを追加するための非常に基本的な方法です。しかし、これらの 2 つのファイルを追加すると (クラス ファイルのコードに到達することはありません)、コンテンツ エディターを開くと次のエラーが表示されます。

SearchConfiguration が正しく構成されていません。ContentSearchConfiguration が予期されていましたが、System.String が返されました。

この単純な構成ファイルがなければ、すべて正常に動作します。

誰かが私がここで間違ったことを見たり、これを修正しようとすることができることを知っていますか?

編集: Sitecore 8 Update 2 を使用しています

4

1 に答える 1