How to handle search term concatenations in SOLR
We are currently replacing our product search from mysql to a SOLR backend. Our customer often开发者_开发技巧 search for terms like 'startrek online', 'starwars', 'redsteel' or even 'grandtheftauto'. Is there a method in SOLR to either expand or spellcheck these searches into syllables eg.'star trek online', 'star wars', 'red steel', 'grand theft auto'?
You can use a synonym file. Take a look into this documenation site (solr.SynonymFilterFactory):
<fieldtype name="syn" class="solr.TextField">
<analyzer>
<tokenizer class="solr.WhitespaceTokenizerFactory"/>
<filter class="solr.SynonymFilterFactory" synonyms="syn.txt" ignoreCase="true" expand="false"/>
</analyzer>
</fieldtype>
For the searchquery splitting the WordDelimiterFilterFactory could match partially your needs, but maybe the synomymfilter is easier and better (+ probably faster).
You can try modifying your search terms using Levenshtein but also making use of SoundEx / Metaphone to improve matches.
http://web.elctech.com/2008/04/13/advanced-solr-filters-with-phonetics/
http://web.elctech.com/2009/07/06/solr-vs-sphinx-fuzzy-search/
精彩评论