Mohan
Mohan

Reputation: 11

How to search arabic words in solr

In my solr schema.xml I defined product arabic name field as below

<field name="productNameArabic" type="text_ar" indexed="true" stored="true"/>
  <fieldType name="text_ar" class="solr.TextField" positionIncrementGap="100">
      <analyzer> 
        <tokenizer class="solr.StandardTokenizerFactory"/>
        <filter class="solr.LowerCaseFilterFactory"/>
        <filter class="solr.StopFilterFactory" ignoreCase="true" words="lang/stopwords_ar.txt" />
        <filter class="solr.ArabicNormalizationFilterFactory"/>
        <filter class="solr.ArabicStemFilterFactory"/>
      </analyzer>
    </fieldType>

In solr search I want to search with product name using Arabic letters. While searching, Arabic user can feel little default to search some product name. Because some characters need to mention while searching.

Ex: إ أ آ

In the above mentioned characters, user can get combination of shift key. Usually if Arabic people will mention “ ا “ character and will get the below combined words.

Ex: إبرا

In my solr schema.xml I defined product arabic name field as below

Upvotes: 1

Views: 1113

Answers (1)

Mysterion
Mysterion

Reputation: 9320

I was able to achieve desired functionality by adding ASCIIFoldingFilter, this filter is able to remove accents from different languages, to make them similar in index time.

<fieldType name="arabic" class="solr.TextField" positionIncrementGap="100">
            <analyzer>
                <tokenizer class="solr.StandardTokenizerFactory"/>
                <filter class="solr.LowerCaseFilterFactory"/>
                <filter class="solr.ASCIIFoldingFilterFactory"/>
                <filter class="solr.StopFilterFactory" ignoreCase="true" words="lang/stopwords_ar.txt" />
                <filter class="solr.ArabicNormalizationFilterFactory"/>
                <filter class="solr.ArabicStemFilterFactory"/>
            </analyzer>
</fieldType>

Some more information about this filter - here. Working code example - here

Upvotes: 0

Related Questions