One day your boss
comes to your office and says "Hey, I want our search engine to be able to find the same documents when I enter phone
or fone
into the search box". You tried to say something, but your boss is already at the other side of the door to your office. So, you wonder if this kind of functionality is available in Solr. I think you already know the answer – yes it is, and this recipe will show you how to configure it and use with Solr.
We start with the following index structure (just add this to your
schema.xml
file, to thefield
section):<field name="id" type="string" indexed="true" stored="true" required="true" /> <field name="name" type="phonetic" indexed="true" stored="true" />
Next we define the
phonetic
type, which looks like the following code (paste it into theschema.xml
file):<fieldtype name="phonetic" stored="false" indexed="true" class="solr.TextField" > <analyzer> <tokenizer class="solr...