Developer forum

Forum » Ecommerce - Standard features » Repository query - special characters

Repository query - special characters

Gaëtan Di Caro
Reply

Hello,

 

I have a search query in my repository which looks in different product fields, including names. Let's say I have a product called "Bjørn". If I search "Bjørn", the search returns it.

Is it possible to make the search also returns this product if I search for "Bjorn" or "Bjoern" ? It doesn't do it right now and I haven't found out how I can do that directly. As a workaround I could have a field with alternative spellings, but it's a lot of work maintaining that.

The solution is using 8.7

Thanks


Replies

 
Gaëtan Di Caro
Reply

Here's a screenshot of the query

2017-04-19_09_52_19-Dynamicweb_8_-_Dynamicweb_Administration.png
 
Nicolai Pedersen
Reply

Hi Gaëtan

You would need to add an analyzer on the field in question to support this. That is done by creating a custom field using an analyzer that normalizes the danish characters:

http://doc.dynamicweb.com/documentation-9/platform/indexing-search/indexing-search#4786

BR Nicolai

 
Gaëtan Di Caro
Reply

Thanks, sounds interesting. I have looked up how to create a custom analyzer in Lucene but I don't know much about it what I have found is pretty esoteric... Do you have any concrete example I could look at ?

Thank you.

 
Nicolai Pedersen
Reply

Here is an article:
https://www.codeproject.com/Articles/32175/Lucene-Net-Text-Analysis

 
Gaëtan Di Caro
Reply

Thanks, I had already read that (along with other explanations and documentation, but it hasn't helped me much, it's really opaque.

I guess I simply need a better knowledge of Lucene, but I don't have time to dig into it that right now. I'll try to find a workaround.

 
Gaëtan Di Caro
Reply

I've found this tutorial which more or less does what I want, I just replaced "GetSynonyms" with my own function to create the alternative spellings : http://www.opten.ch/blog/2014/05/30/writing-a-custom-synonym-token-filter-in-lucenenet/

Then I use it in my analyser like this :

public class DanishAnalyzer : Analyzer
    {
        public override TokenStream TokenStream(string fieldName, TextReader reader)
        {
            TokenStream tokenStream = new KeywordTokenizer(reader);
            tokenStream = new DanishFilter(tokenStream);

            return tokenStream;
        }
    }

Then I created a new field type with this analyser, and a new field with this field type which takes its source from name, and my query searches this field (match any).

 

But it still doesn't work.

 
Gaëtan Di Caro
Reply

Anyone with Lucene experience to give me a hand ?

Thanks

 

You must be logged in to post in the forum