Ran into this issue the other day but can't find anything yet (from googling) that addresses this issue.
I am using Solr as my indexing engine. I am trying to index a image field in my template. Indexing is working fine but it's not indexing the media URL (that I am returning from my code) instead it's indexing the ALT text of the image. If the ALT text is not present only then it's indexing the media URL. I have my index configuration in a separate file.
I think the below line in the default Sitecore.ContentSearch.Solr.DefaultIndexConfiguration.config file is probably messing with my config. But how do I overwrite this only for "main_image" field.
<fieldReader fieldTypeName="image" fieldReaderType="Sitecore.ContentSearch.FieldReaders.ImageFieldReader, Sitecore.ContentSearch" />
Below is how my configuration looks like:
<?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>
One of the implementations looks like below (the other one is similar)
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);
}
}
Could anyone please shed some light here on how to resolve this issue.
Thanks in advance.
P.S> I have seen John West's post here http://www.sitecore.net/de-de/learn/blogs/technical-blogs/john-west-sitecore-blog/posts/2013/05/sitecore-7-pre-render-image-fields.aspx