solrnewbie
solrnewbie

Reputation: 33

Solr synonyms aren't working right

We have a large restaurant menu database where users can search for menu items. There are many items that when the words are side by side its a unique dish but the words are so common and appear all over the place.

Example: Users want to search for "cheese steak" In the database...it can be "cheesesteak" or "cheese steak"

In my synonym file I have:

cheesesteak     => cheesesteak, cheese steak
cheese steak    => cheesesteak, cheese steak

When I search for "cheesesteak", I get valid results. I get menu items with "cheesesteak" and also "cheese steak" (words side by side)

But when I search for "cheese steak", I get all kinds of non relevant results like "steak salad with blue cheese" its picking up anything with the words cheese and steak

Is there a way to configure this synonym file so it works? I don't want to force user to enter quotes, etc.

Upvotes: 2

Views: 329

Answers (2)

Persimmonium
Persimmonium

Reputation: 15791

what you should do is use edismax and let boosting show the most relevant docs. You can also do this by using standard handler if you add boosting queries or optional phrase with all terms like +cheese +steak ("cheesesteak"^100 "steak cheese"^50)

Upvotes: 0

mguymon
mguymon

Reputation: 9015

What you are looking for is proximity search, were scoring improves with the correct ordering and distance of words. From the Solr FAQ

A proximity search can be done with a sloppy phrase query. The closer together the two terms appear in the document, the higher the score will be. A sloppy phrase query specifies a maximum "slop", or the number of positions tokens need to be moved to get a match.

This example for the standard request handler will find all documents where "batman" occurs within 100 words of "movie":

q=text:"batman movie"~100

Upvotes: 1

Related Questions