Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Im trying to build a search function for a site that is in swedish. I am able to search, but when i search with swedish characters ( Å Ä Ö ) it does not work.
For example if i search for Göteborg i get 0 hits, but if i instead use the term Goteborg it works.
Anybody got a solution? Do i need to configure the index for multilanguage?
Thanks in advance!
Hello Daniel! I'm having the same issue for swedish characters? Were you able to solve this?
Are you doing a wildcard search? So during indexing it will run through standard analyser (thats if you have not changed it to another analyser) and it will ascii flatten characters so ( Å Ä Ö ) will go in as (a a o) also during searching it will do same thing so it should all work.
If you are doing wildcard searching then if i remember rightly it wont ascii flatten the query so it searches literally on those characters but in examine / lucene it has the flattened characters.
I recall covering this or having this in the notes on examine course so the code I have is:
public class AsciiFoldingFilter
private readonly Analyzer _analyzer;
// We are analyzing the query before adding the wildcards
// This way the words containg diactrics (characters specific to a language)
// will be folded to ASCII character set.
// e.g. word "weiß Glückwunsch" will be flattened into "weiss gluckwunsch"
// When the wildcards are added before analyzing, then the text will not be analyzed
public AsciiFoldingFilter(BaseSearchProvider baseSearchProvider)
var luceneSearch = (BaseLuceneSearcher)baseSearchProvider;
_analyzer = luceneSearch.IndexingAnalyzer;
public AsciiFoldingFilter(Analyzer analyzer)
_analyzer = analyzer;
public string FlattenToAscii(string stringToFold)
var parser = new QueryParser(
var query = parser.Parse(stringToFold.Trim());
On the query side before you wildcard it run the query through this AsciiFoldingFilter then wildcard and it should work.
Thanks for the reply. After some investigation on my own i found out that i was indeed the wildcard search that did flatten the swedish characters. I did try it with a fuzzy search and it worked aswell.
Thanks for the code. I will try that solution out.
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted