Created
December 19, 2016 11:47
-
-
Save NaibafCH/4c6c28dc2eb97aa423bf3a1c2637d0f3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using Sitecore.ContentSearch.ComputedFields; | |
using Sitecore.Data.Items; | |
using Sitecore.Diagnostics; | |
namespace Sitecore.ContentSearch.Search.ComputedFields | |
{ | |
public class AutoCompleteTitle : IComputedIndexField | |
{ | |
public object ComputeFieldValue(IIndexable indexable) | |
{ | |
if (indexable == null) throw new ArgumentNullException("indexable"); | |
var scIndexable = indexable as SitecoreIndexableItem; | |
if (scIndexable == null) | |
{ | |
Log.Warn( | |
this + " : unsupported IIndexable type : " + indexable.GetType(), this); | |
return false; | |
} | |
var item = (Item)scIndexable; | |
if (item == null) | |
{ | |
Log.Warn( | |
this + " : unsupported SitecoreIndexableItem type : " + scIndexable.GetType(), this); | |
return false; | |
} | |
if (string.Compare(item.Database.Name, "core", StringComparison.OrdinalIgnoreCase) == 0) | |
{ | |
return false; | |
} | |
return item["Title"]; | |
} | |
public string FieldName { get; set; } | |
public string ReturnType { get; set; } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment