World is now on Opti ID! Learn more

Partial-word matching not working in EPiServer Search

Vote:
 

Hi All,

We are on CMS 12.32 and EPiServer Find 16.3.1 and need alignment on below used case.
 
User Scenario:
  • We have a page/file with name as "23_samples" and get indexed in EPiServer Search. 
  • When user is trying to search for keyword "samples", we are not getting the 23_samples file in search result.
  • Is this expected or the search will only be able to return the content with samples keyword only.

 

#339556
Jun 30, 2025 11:50
Vote:
 

As per support:

Looks like this needs to be changed in our backend - I am not at this time sure when or if this can happen but it will take time.
 
For now you should be able to index an extra field where you replace underscore with hyphen or what makes most sense and query on it.
Is it a built in property or a custom property that contains this data? Yes I understand this is a bit hackish but I don't think there is an alternative at this time.
 
public class File
{
public string Name { get; set; }

public string NameWithoutUnderscore
{
   get => Name?.Replace("_", "-");
   set
   {
   }
}

}
#339557
Edited, Jun 30, 2025 11:51
Vote:
 

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.

#339558
Edited, Jul 01, 2025 4:47
Eric Herlitz - Jul 01, 2025 7:45
Brilliant, however, isn't this solution for Search & Navigation?
Vote:
 

Hi,

 

You could also look into this tool or get inspiration from their wildcardMatch functionality.

https://github.com/episerver/EPiServer.Labs.Find.Toolbox

#339564
Jul 01, 2025 7:17
Eric Herlitz - Jul 01, 2025 7:46
That's Find (Search & Navigation), Rajveer is asking about Episerver Search which is another product.
Stefan Holm Olsen - Jul 01, 2025 7:50
From my understanding leading wildcard is not permitted. Only trailing wildcard. And so that would not work for this scenario.
Mathias Andersson - Jul 01, 2025 8:09
From the description it's my understanding that they are using Find.
"We are on CMS 12.32 and EPiServer Find 16.3.1"
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.