Here is another way, without using synonyms: in data preparation, you can create a new token 'bats_sports' for all common words in different categories. You can do this in a separate field that you do not store, just index. Now, if you search with a category you would send in 'bats bats_sports' and boost results from this other field.
----- Original Message ----- | From: "Carrie Coy" <c...@ssww.com> | To: solr-user@lucene.apache.org | Sent: Wednesday, September 19, 2012 2:20:49 PM | Subject: Re: Conditionally apply synonyms? | | the latter: the document (eg product) has a category, and the | synonyms | would be applied at index time. sports-related "bat" synonyms to | baseball "bats", and halloween-themed "bat" synonyms to scary "bats", | for example. | | | On 09/19/2012 05:08 PM, Erick Erickson wrote: | > Not that I know of, synonyms are an all-or-nothing on a field. | > | > But how would you indicate the context at index time as opposed to | > query time? Especially at query time, there's very little in the | > way of | > context to figure out what the category was. | > | > Or were you thinking that the document had a category and applying | > this only at index time? | > | > Best | > Erick | > | > On Wed, Sep 19, 2012 at 3:23 PM, Carrie Coy<c...@ssww.com> wrote: | >> Is there an existing TokenFilterFactory that can conditionally | >> insert | >> synonyms based on a given document attribute, say category? Some | >> synonyms | >> only make sense in context: "bats" in Sports is different from | >> "bats" in | >> "Party and Novelty". | >> | >> It seems the synonyms.txt file would need an additional column | >> that could be | >> checked against the document attribute prior to appending | >> synonyms: | >> | >> *#synonyms category* | >> post,pole sports | >> wheel,caster furniture | >> pat,paddy,patrick holiday | >> | >> Is anything like this possible without writing a custom | >> TokenFilterFactory? |