Sometimes, stemmers provided with Lucene and Solr don't do what you would like them to do. That's because most of them are based on an algorithmic approach and even the best algorithms can come to a place where you won't like the results of their work and you would like to make some modifications. Of course, modifications to the algorithm code can be challenging and we don't usually do that. The good thing is that Solr supports a method of overriding the stemmer work and this recipe will show you how to use it.
Before we continue please remember that the method described in this recipe may not work with custom stemmers that are not provided with Solr.
How to do it...
Let's say that we want some of the words to be stemmed in a way we want. For example, we want the word dogs
to be stemmed as doggie
(of course that's only an example).
What we have to do first is write the words
dogs
anddoggie
in a file (let's call itoverride.txt
). Words should...