0
votes

Scenario: eCommerce - Product search.

Is there a feature in SOLR that allow us to add STOP Words or "Keywords to ignore " per Product?

Example:

Search word: :Maker":

Expected results: ABC Coffee Maker, XYZ Juice Maker, MNO Label Maker, DEF Coffee Maker.

Search word: :Coffee Maker":

Expected results: ABC Coffee Maker, XYZ Juice Maker, DEF Coffee Maker.

MNO Label Maker should not be displayed when user searches for "Coffee Maker"

Thanks, Jitendra.

3

3 Answers

0
votes

The only way I know how to do what you want is to search on a phrase and give it a good boost. Here's an example from one of my own queries:

desc_search:(20%^10.0 AND SMD^10.0 OR "20% SMD"^100.0)

Note the "20% SMD" in quotes. This tells Solr to search on that exact phrase and boost documents that contain it. Depending on your boosting scheme, 100.0 may be too much or too little, so you'll need to experiment.

You'll still have the unrelated searches down near the bottom of the results list.

I haven't noticed any speed or efficiency issues yet with this approach, but I imagine if you let a user search on a super common word like "the", "and", etc., you could see a lot of results coming back and that could slow things down a little. I've had as many as 10K docs come back without problems, though.

0
votes

If the desired behavior is to show all "makers" but prioritize "coffee makers", then boosting (phrases or shingles as above) is the way to go.


If, instead you want all coffee makers and no label makers for the search coffee maker, then just have your client code do this:

  1. Run a phrase search for "coffee maker"
  2. If no results are found, then optionally, run the normal term search before displaying results.
0
votes

To remove stop words

  • Add the stopwords filter to your fieldType in schema.xml solr/collection1/conf/schema.xml

  • Customize the stopwords.txt list solr/collection1/conf/stopwords.txt

  • restart solr

Words in the stopwords list will be excluded @ index time