November Happy Hour will be moved to Thursday December 5th.
AI OnAI Off
November Happy Hour will be moved to Thursday December 5th.
Hi Steven
You can add the categories property to your indexed object(s) as follows:
[ModuleDependency(typeof(EPiServer.Web.InitializationModule))] public class AddGetaCategoriesInitialization : IInitializableModule { private static readonly ILogger Logger = LogManager.GetLogger(); private bool _initialized; public void Initialize(InitializationEngine context) { if (_initialized || context.HostType != HostType.WebApplication) { return; } SearchClient.Instance.Conventions.ForInstancesOf<PageTypeWithGetaCategories>().IncludeField(x => x.GetaCategories()); _initialized = true; } public void Uninitialize(InitializationEngine context) { } }
Then use the extension method as following:
public static List<string> GetaCategories(this object content) { if (content is PageTypeWithGetaCategories page) { return ConvertToList(page.GetaCategoriesPropertyName); } return new List<string>(); }
Then facet as usual using .TermsFacetFor(x => x.GetaCategories()) and query using query = query.FilterHits(x => x.GetaCategories().Match(categorySearchTerm);
David
We are using the Geta Epi Categories in out solution https://github.com/Geta/EpiCategories. We are using version 1.2.1.
Is there a way to use the Geta Epi Categories in the unified search method. The CMS users will be assigning categories to content with the Geta Categories property type (IList). The Unified Search Search Categories property is of the IEnumerable type so was wondering if this is possible and a nudge in the right direction to do this
Thanks in advance!