I suppose I could translate every user query to include the term with quotes.
e.g. if someone searches for stock syrup I send a query like: q=stock syrup OR "stock syrup" Seems like a bit of a hack though, is there a better way of doing this? Zac -----Original Message----- From: Zac Smith Sent: Sunday, February 05, 2012 7:28 PM To: solr-user@lucene.apache.org Subject: RE: Multi word synonyms Thanks for the response. This almost worked, I created a new field using the KeywordTokenizerFactory as you suggested. The only problem was that searches only found documents when quotes were used. E.g. synonyms.txt setup like this: simple syrup,sugar syrup,stock syrup I indexed a document with the value 'simple syrup'. Searches only found the document when using quotes: e.g. "simple syrup" or "stock syrup" matched simple syrup (no quotes) did not match Here is the field I created: <fieldType name="synonym_searcher" class="solr.TextField" positionIncrementGap="100" autoGeneratePhraseQueries="true"> <analyzer type="index"> <charFilter class="solr.MappingCharFilterFactory" mapping="mapping-ISOLatin1Accent.txt" /> <tokenizer class="solr.KeywordTokenizerFactory" /> <filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true" tokenizerFactory="solr.KeywordTokenizerFactory" /> <filter class="solr.LowerCaseFilterFactory" /> </analyzer> <analyzer type="query"> <charFilter class="solr.MappingCharFilterFactory" mapping="mapping-ISOLatin1Accent.txt" /> <tokenizer class="solr.KeywordTokenizerFactory" /> <filter class="solr.LowerCaseFilterFactory" /> </analyzer> </fieldType> Any ideas? Also, I am using dismax and solr 3.5.0. Thanks Zac -----Original Message----- From: O. Klein [mailto:kl...@octoweb.nl] Sent: Sunday, February 05, 2012 5:22 AM To: solr-user@lucene.apache.org Subject: Re: Multi word synonyms Your query analyser will tokenize "simple sirup" into "simple" and "sirup" and wont match on "simple syrup" in the synonyms.txt So you have to change the query analyzer into KeywordTokenizerFactory as well. It might be idea to make a field for synonyms only with this tokenizer and another field to search on and use dismax. Never tried this though. -- View this message in context: http://lucene.472066.n3.nabble.com/Multi-word-synonyms-tp3716292p3717215.html Sent from the Solr - User mailing list archive at Nabble.com.