Elasticsearch Accent insensitive search

Hi, i’m trying to add accent insensitive search for elasticsearch.
I want to add a AsciiFolding tokenfilter that preservs the original characters so it’s possible to search with or withouth the accent for example “e” and “é” should be handle the same, ex: if a brand name would be original “èrgonomica” searching at “ergo” or “érgo” should yield the same results.

What I’v tried to do is to override the “BuildIndexDescriptor” for the document type im searching at: (the class inherits from “MultilingualIndexConfigurationBase”). As I understand it, this is the class that will handle the configuration for that type off searchable entity?

protected override CreateIndexDescriptor BuildIndexDescriptor(CultureInfo cultureInfo, CreateIndexDescriptor descriptor)
        {
			return descriptor.Settings(s => s
				 .Analysis(analysis => analysis
					 .TokenFilters(tokenfilters => tokenfilters
						 .AsciiFolding("folding-preserve", ft => ft
							 .PreserveOriginal()
						 )
					 )
					 .Analyzers(analyzers => analyzers
						 .Custom("folding-analyzer", c => c
							 .Tokenizer("standard")
							 .Filters("standard", "folding-preserve")
						 )
					 )
				 )
			 ).Map<Category>(mm => mm
				 .AutoMap()
				 .Properties(p => p
					 .Text(t => t
						 .Name(n => n.Localizations[cultureInfo].Name)
						 .Analyzer("folding-analyzer")
					 )
				 )
			 );
        }

Though, this code dosent get hit when im trying to debug it, im now wondering if this is the place to add my custom analysers and mappers for special properties that need special handling when searching.
Litium version: 7.7.0

Yes, it’s the correct place to modify how the index should be created. The mapping should be moved into the method BuildTypeMapDescriptor instead to not override the default behaviour.

The index is only created if not already existing so changing this for an existing index will not be applied before you delete the index or change the index prefix so a new index is created.

Do you have a suggested approach to recreate the index? Or another solution for this so we dont have to recreate index in production. We will do this for both Category and Product index.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.