Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You could add a computed field. <a href="http://www.sitecore.net/Community/Technical-Blogs/John-West-Sitecore-Blog/Posts/2013/03/Sitecore-7-Computed-Index-Fields.aspx" rel="nofollow">Here is John West's post about it.</a> Below is a condensed example to get just the URL of the image.</p> <p>Create a class that implements Sitecore.ContentSearch.ComputedFields.IComputedIndexField.</p> <pre><code>public class ImageIndexField : IComputedIndexField { 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["MyImageField"]; return img == null || img.MediaItem == null ? null : MediaManager.GetMediaUrl(img.MediaItem); } } </code></pre> <p>Then, add a config include with something like this:</p> <pre><code>&lt;sitecore&gt; &lt;contentSearch&gt; &lt;configuration type="Sitecore.ContentSearch.LuceneProvider.LuceneSearchConfiguration, Sitecore.ContentSearch.LuceneProvider"&gt; &lt;defaultIndexConfiguration type="Sitecore.ContentSearch.LuceneProvider.LuceneIndexConfiguration, Sitecore.ContentSearch.LuceneProvider"&gt; &lt;fields hint="raw:AddComputedIndexField"&gt; &lt;field fieldName="MyImageFieldUrl" storageType="YES" indexType="TOKENIZED"&gt;sc70.Search.ComputedFields.ImageUrlIndexField, sc70&lt;/field&gt; &lt;/fields&gt; &lt;/defaultIndexConfiguration&gt; &lt;/configuration&gt; &lt;/contentSearch&gt; &lt;/sitecore&gt; </code></pre> <p>Note that the field name is hard coded above. I'm not sure if it is possible to pass that in as a parameter from the config. Sitecore seems to be creating separate classes for each of their computed fields and using inheritance to get reuse.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload