World is now on Opti ID! Learn more
AI OnAI Off
World is now on Opti ID! Learn more
As per support:
Hi Rajveer
Sounds like the word analyzer is not recognizing the underscore as a word delimiter.
If you don't really need that new property anywhere else, I would personally make it as an index convention, instead of a model property. Something like this (clean it up at your own discretion):
using EPiServer.Core;
using EPiServer.Find.ClientConventions;
using EPiServer.Find.Cms;
using EPiServer.Find.Cms.Conventions;
using EPiServer.Find.Cms.Module;
using EPiServer.Find.Framework;
using EPiServer.Framework;
using EPiServer.Framework.Initialization;
using EPiServer.ServiceLocation;
namespace MySite.Search
{
[InitializableModule]
[ModuleDependency(typeof(IndexingModule), typeof(ServiceContainerInitialization))]
public class SearchInitialization : IInitializableModule
{
public void Initialize(InitializationEngine context)
{
var clientConventions = SearchClient.Instance.Conventions;
// Include/exclude custom properties.
clientConventions.ForInstancesOf<PageData>()
.IncludeField(x => x.SanitizedName());
}
public void Uninitialize(InitializationEngine context)
{
}
}
public static class ContentExtensions
{
public static string SanitizedName(this PageData pageData)
{
// Replace chars instead of single-char strings.
return pageData?.Name?.Replace('_', '-');
}
}
}
If you need to filter on it, you can just call that extension method in your filter. Then S&N will turn the method name into a field name in the query.
Hi,
You could also look into this tool or get inspiration from their wildcardMatch functionality.
https://github.com/episerver/EPiServer.Labs.Find.Toolbox
Hi All,