先日この問題に遭遇しましたが、この問題に対処するものは (グーグルから) まだ見つかりません。
インデックス作成エンジンとして Solr を使用しています。テンプレートの画像フィールドにインデックスを付けようとしています。インデックス作成は正常に機能していますが、メディア URL (コードから返されたもの) のインデックス作成ではなく、画像の ALT テキストのインデックス作成です。ALT テキストが存在しない場合のみ、メディア URL のインデックスが作成されます。別のファイルにインデックス構成があります。
デフォルトの Sitecore.ContentSearch.Solr.DefaultIndexConfiguration.config ファイルの以下の行は、おそらく私の設定をいじっていると思います。しかし、これを「main_image」フィールドだけに上書きするにはどうすればよいですか。
<fieldReader fieldTypeName="image" fieldReaderType="Sitecore.ContentSearch.FieldReaders.ImageFieldReader, Sitecore.ContentSearch" />
以下は私の構成がどのように見えるかです:
<?xml version="1.0" encoding="utf-8" ?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<myindex>
<indexConfigurations>
<mySolrIndexConfiguration ref="contentSearch/indexConfigurations/defaultSolrIndexConfiguration">
<fields hint="raw:AddComputedIndexField">
<field fieldName="main_image" returnType="text">My.Indexing.Namespace.MyMainImageIndexing,My.Indexing</field>
<field fieldName="thumbnail" returnType="text">My.Indexing.Namespace.MyThumbnailIndexing,My.Indexing</field>
</fields>
</mySolrIndexConfiguration>
</indexConfigurations>
</myindex>
</sitecore>
</configuration>
実装の1つは以下のようになります(もう1つは同様です)
public class MyMainImageIndexing : IComputedIndexField
{
public string Parameters { get; set; }
public string FieldName { get; set; }
public string ReturnType { get; set; }
public object ComputeFieldValue(IIndexable indexable)
{
Assert.ArgumentNotNull(indexable, "indexable");
var indexableItem = indexable as SitecoreIndexableItem;
if (indexableItem == null)
{
Log.Warn(string.Format("{0} : unsupported IIndexable type : {1}", this, indexable.GetType()), this);
return null;
}
ImageField img = indexableItem.Item.Fields["Main Image"];
return (img == null || img.MediaItem == null) ? null : MediaManager.GetMediaUrl(img.MediaItem);
}
}
この問題を解決する方法について、誰かがここに光を当ててください。
前もって感謝します。
PS> ここで John West の投稿を見ましたhttp://www.sitecore.net/de-de/learn/blogs/technical-blogs/john-west-sitecore-blog/posts/2013/05/sitecore-7-pre -render-image-fields.aspx