Examine Search german characters (ä, ö, ü...)
# help-with-umbraco
p
Hey everyone, currently my examine query does not give me any search results for a input with any german character... How can i configure examine to recognize and search for them?
h
d
You might be able to do this by replacing the standard analyzer with a german analyzer. If it's not multilingual, that is: https://lucene.apache.org/core/5_1_0/analyzers-common/org/apache/lucene/analysis/de/GermanAnalyzer.html
p
@User May I suggest “Umbracians” instead of "guys"? We use gender inclusive language in this Discord. 😀
p
Thanks @huwred and @D_Inventor for your replys. You always help me if theres something not working for me :D. Where would i have to implement the german analyzer?
d
The german analyzer can be installed in a package (not sure what the name is atm.). Then you can assign the analyzer in the options configure thingy, let me find an example for you. I recently did the same with a Dutch analyzer
You always ask nice and clear questions, it's enjoyable to help you out 😄
The package is likely called something along the lines of
Lucene.Net.Analysis.De
. Then you create a configure class like this:
Copy code
csharp
public class ConfigureMyIndex : IConfigureNamedOptions<LuceneDirectoryIndexOptions>
{
    public void Configure(string name, LuceneDirectoryIndexOptions options)
    {
        if (!name.Equals("ExternalIndex", StringComparison.Ordinal)) return;

        options.Analyzer = new DutchAnalyzer();
    }

    public void Configure(LuceneDirectoryIndexOptions options)
    {
        throw new NotImplementedException("This method is just part of the interface, but is not actually being used");
    }
}
And obviously register that in dependency injection
s
I'm trying to search for what we call product and sparepart pages using umbraco examine but when I do it programatically, I get hundreds of unrelated results The query looks like this var searchCriteria = index.Searcher.CreateQuery("content", BooleanOperation.Or); var searchQuery = searchCriteria .Field("nodeName", query).Or() .Field("keywords", query).Or() .Field("sparepartName", query) .Execute(); Examine management returns the right results but when I search for example "Product1" using above code, it basically returns every product page in the system Am I doing something obviously wrong that I'm just not seeing?
p
@D_Inventor Thank you so much! I'll give it a try and let you know 😄
s
I think I solved my problem by changing it to luceneSearcher.Search(query) which gave me the same results as in examine management
p
Seems like the german analyzer is loaded correctly for the internal index and is also shown in the backoffice. I've rebuilt both Internal and External Index but unfortunately it does not work for me if i search for something with ä ö or ü. Maybe it has to do something with the GermanAnalyzer which is not capable of this function to match ä ö or ü. I will have a deeper look into the german analyzer maybee i will find something 😄