Example Indexing - Hendy/umbraco-look GitHub Wiki

The index setters would typically be set in an Umbraco startup event (but they can be changed at any-time). Eg.

public class ConfigureIndexing : ApplicationEventHandler
{	
	/// <summary>
	/// Umbraco has started event
	/// </summary>
	protected override void ApplicationStarted(
				UmbracoApplicationBase umbracoApplication, 
				ApplicationContext applicationContext)
	{				
		// Eg. prevent hooking into any Examine indexers (only Look indexers will be used)
		LookConfiguration.ExamineIndexers = null;

		// Eg. index dates for news articles differently
		LookConfiguration.DefaultDateIndexer = indexingContext => { 
			
			if (indexingContext.Item.DocumentTypeAlias == "newsArticle") 
			{
				return indexingItem.GetPropertyValue<DateTime>("releaseDate");
			}

			return indexingContext.Item.UpdateDate; 
		};

		// Eg. configure indexing for a specific indexer 
		LookConfiguration.IndexerConfiguration["MapIndexer"] = new IndexerConfiguration()
		{
			// only index content
			ItemTypes = new[] { ItemType.Content },

			// only index specific aliases
			Aliases = new[] { "thing" },

			// set location indexer
			LocationIndexer = indexingContext => {

				// eg. using Terratype			 
				var terratype = indexingContext.Item.GetPropertyValue<Terratype.Models.Model>("location");
				var terratypeLatLng = terratype.Position.ToWgs84();

				return new Location(terratypeLatLng.Latitude, terratypeLatLng.Longitude);
			}
		};
	}
}
⚠️ **GitHub.com Fallback** ⚠️