Akhil Valayil
Akhil Valayil

Reputation: 49

How can I implement fuzzy search using solr

For example, I have got a name with first name, middle name and last name. I need to search different combinations of name like {first name, middle name, last name},{middle name, first name, last name} and so on(6 combinations). In the mean time, names must be search with phonetic also. Like for the name "John", it must pick "Jonn". Also for "Mohammed" it must make a hit "Mohammad" or "Mouhammed" This phonetic search is applicable for all the three parts of name.

Upvotes: 0

Views: 1101

Answers (1)

Ashraful Islam
Ashraful Islam

Reputation: 12830

Use fieldType phonetic_en for name

Field Type phonetic_en included in the default schema, If not use the below schema :

<fieldType name="phonetic_en" stored="false" indexed="true" class="solr.TextField" >
  <analyzer>
    <tokenizer class="solr.StandardTokenizerFactory"/>
    <filter class="solr.DoubleMetaphoneFilterFactory" inject="false"/>
  </analyzer>
</fieldType>

Example :

<field name="cfname" type="phonetic_en" indexed="true" stored="false"/>

DoubleMetaphoneFilterFactory :

This filter creates tokens using the DoubleMetaphone encoding algorithm from commons-codec. For more information, see the Phonetic Matching section.

Upvotes: 1

Related Questions