If query-side multi-term synonyms are important to your application, your best bet may be to implement a preprocessor that expands them to an OR sequences of phrases before submitting the query to Solr. That would also give you an opportunity to boost a preferred synonym.

For example, a user query of

abc John Cena xyz

would be preprocessed and sent to Solr as

abc ("John Cena" OR "Cena John") xyz

You could also consider using phrase slop to handle simple name reversal:

abc "John Cena"~1 xyz

That would also allow a middle initial or name, for example. But, you need to consider whether you really want that. The simple phrases give you explicit control.

If the synonym is in a phrase, you might need to consider re-generating the entire phrase:

abc "def John Cena uvw" xyz

to

abc ("def John Cena uvw" OR "def Cena John uvw") xyz

As a side note, the query parser in LucidWorks Enterprise (and LucidWorks Cloud) does support multi-term synonyms at query term for normal text fields, but it does so by bypassing the the processing of the Solr synonym filter and simply using the synonym file to preprocess the query terms before completing the term analysis. But, that won't do you any good if you are not using the Lucid products.

-- Jack Krupansky

-----Original Message----- From: Noordeen, Roxy
Sent: Thursday, May 03, 2012 9:08 AM
To: solr-user@lucene.apache.org
Subject: RE: synonyms

Jack,
I am also using synonyms at query side, but so far i am able to use only single words to work, multi words is not working for me. I didn't want to use synonyms during indexing, to avoid re indexing.

Is there a way for solr to support multi words?
Ex:
John Cena, John, Cena
Or
Triple H, DX, tripleh, hhh.

Thanks
Roxy


-----Original Message-----
From: Jack Krupansky [mailto:j...@basetechnology.com]
Sent: Wednesday, May 02, 2012 8:53 PM
To: solr-user@lucene.apache.org
Subject: Re: synonyms

There are lots of different strategies for dealing with synonyms, depending
on what exactly is most important and what exactly your are willing to
tolerate.

In your latest example, you seem to be using string fields, which is
somewhat different form the text synonyms we talk about in Solr. You can
certainly have multiple string fields, or even a multi-valued string field
to store variations on selected categories of terms. That works well when
you have a well-defined number of categories. So, you can have a user query
go against a combination of normal text fields and these category string
fields.

If that is sufficient for your application, great.

-- Jack Krupansky

-----Original Message----- From: Carlos Andres Garcia
Sent: Wednesday, May 02, 2012 6:57 PM
To: solr-user@lucene.apache.org
Subject: RE: synonyms

Thanks for your answers, now I have another cuestions,if I develop the
filter to replacement the current synonym filter,I understand that this
procces would be in time of the indexing because in time of the query search
there are a lot problems knows. if so, how can I do for create my  index
file.

For example:
I have two synonyms "Nou cam", "Cataluña"  for  barcelona  in the data base


Opcion 1)
In time of the indexing would create 2 records like this:

<doc>
  <field>barcelona<field>
  <field>Camp Nou<field>
...
<doc>

and

<doc>
  <field>barcelona<field>
  <field>Cataluña<field>
...
<doc>

Opcion 2)

or only would create  one record like this:

<doc>
  <field>barcelona<field>
  <field>Camp Nou,Cataluña<field>
...
<doc>


If it create the opcion 2 can looking for by Camp Nou y by Cataluña but when
I looking for by barcelona the Solr return 2 records and that is one error
because barcelona is only one

IF it create the opcion 2 , I have searching wiht wildcards for example
*Camp Nou* o *Cataluña* y the solr would return one records, the same case
if searching by barcelona solr would return one recors that is good , but i
want to know if is the better option or solr have another caracteristic
betters  that can resolve this topic of one better way.

Reply via email to