Set the title’s analyzer to fr so cafe finds “Café” without changing the displayed text.
dotnet add package RecursiveAI.OneIndex --prereleaseRequires .NET 10 (net10.0); .NET 9 and earlier aren’t supported.
using OneIndex; using var index = SearchIndex.InMemory<Note>(); index.Upsert(new Note { Id = "1", Title = "Café à Paris" }); index.Upsert(new Note { Id = "2", Title = "Le café du matin" }); index.Upsert(new Note { Id = "3", Title = "Thé à Lyon" }); index.Commit(); // The trailing space ends the word. foreach (var hit in index.Search("cafe ")) Console.WriteLine(hit.Document.Title); public class Note { [SearchId] public string Id { get; set; } = ""; [FullText(Language = "fr")] public string Title { get; set; } = ""; }
Café à Paris Le café du matin
The full program
Unzip the example, then dotnet run.
The download indexes the same three titles twice, once with [FullText(Language = "fr")] and once with plain [FullText]. Search analyzes each query using the field’s analyzer. The trailing space marks the input as a completed word so the example doesn’t test prefix search. The default analyzer folds case but keeps accents: cafe gives no hits there, while café gives two.
using OneIndex; Note[] notes = [ new() { Id = "1", Title = "Café à Paris" }, new() { Id = "2", Title = "Le café du matin" }, new() { Id = "3", Title = "Thé à Lyon" }, ]; using var french = SearchIndex.InMemory<Note>(); using var standard = SearchIndex.InMemory<StandardNote>(); foreach (var note in notes) { french.Upsert(note); standard.Upsert(new StandardNote { Id = note.Id, Title = note.Title }); } french.Commit(); standard.Commit(); foreach (string word in new[] { "cafe", "café" }) { // A trailing space marks the word as complete. string query = word + " "; Console.WriteLine($"fr, {word}:"); foreach (var hit in french.Search(query)) Console.WriteLine($" {hit.Document.Title}"); Console.WriteLine($"standard, {word}: {standard.Search(query).Execute().Count}"); } public class Note { [SearchId] public string Id { get; set; } = ""; [FullText(Language = "fr")] public string Title { get; set; } = ""; } public class StandardNote { [SearchId] public string Id { get; set; } = ""; [FullText] public string Title { get; set; } = ""; }
dotnet run prints:
fr, cafe: Café à Paris Le café du matin standard, cafe: 0 fr, café: Café à Paris Le café du matin standard, café: 2
Variations
Readers can type the accent too. Replace the foreach loop in the snippet at the top with:
foreach (var hit in index.Search("café ")) Console.WriteLine(hit.Document.Title);
Café à Paris Le café du matin
Related recipes
- Add full-text search in C#
- Rebuild a search index from source data
- Search document titles by word prefix
The short answer
Put [FullText(Language = "fr")] on the French title property and pass the original query text to index.Search. OneIndex uses the field’s analyzer for both the title and the query, so cafe and café both find the same accented titles here. Keep the original title for display.
How do you search text without accents in C#?
An analyzer turns text into searchable terms. The French analyzer splits the text into words, folds case, and applies French language rules including elision, stop words, and stemming. Stemming reduces related word forms to shared search terms. Accent folding runs after stemming because the stemmer can use accented letters. The source documents this order in Analyzers.cs.
Set the language for the text you actually index. The French analyzer is not a switch that only ignores accents: it can also remove common French words and change the terms that represent other words. Since stemming happens first, don’t assume that every accented word and every unaccented spelling will end up with an identical term. Try representative names and words from your own collection before changing a field that readers already search.
OneIndex has other language analyzers, including Spanish (es) and Italian (it) with accent folding, but no built-in accent-only analyzer.
Is case-insensitive search the same as accent-insensitive search?
No. Under the standard analyzer, case folding makes Café and café searchable as the same word, but cafe lacks the accent that is still present in the indexed term. Lowercasing the input, or removing accents just from the query, doesn’t make an index built with the standard analyzer accent-insensitive. The download gives the standard and French indexes the same titles and both spellings, so the difference comes from the analyzer, not the data.
Can you make an existing full-text field accent-insensitive without reindexing?
Not by changing only the query. The old field still contains terms made by the original analyzer. OneIndex’s mapping guide says opening an existing index with a different schema fails and schema evolution isn’t built in. Create a new index with the updated mapping and populate it with your original documents. Run sample queries against that index before switching your app to it, including both accent spellings and any words whose treatment by the language analyzer matters to readers.