1

I've got this problem that I can't solve. Partly because I can't explain it with the right terms. I'm new to this so sorry for this clumsy question.

Below you can see an overview of my goal.

I'm using Magento CE 1.7.0.2 & Solr 4.6.0.

Here you can see my goal..

I'm Search for the products with the word adidas black

Here i can see my results

http://127.0.0.1:8080/solr/collection1/select?q=adidas+black

i got around 600 products but i found its searching for the products of adidas and black and adidas black.

its giving these all results but i want only adidas black.

How can i get these products directly from Solr.

Any ideas ?

Naresh
  • 681
  • 2
  • 12
  • 39

2 Answers2

2

You have few options, but the short answer in your case is to put double quotes around your query terms, example:

http://127.0.0.1:8080/solr/collection1/select?q="adidas+black"

Besides the double quotes, you can also specify another parameter - qs (Query Slop), which tells how far apart the terms can appear, and still considered a match. If you say qs=0, means they have to come exactly next to each other. If you say qs=1, it means, one term could be in the middle, so 'adidas shoes black' would still match

So, you can have a query like this:

http://127.0.0.1:8080/solr/collection1/select?q="adidas+black"&qs=2

Another alternative, which is my favorite, is to leave out the double quotes, and add the mm (minimum match criteria). You can set it to 100% if you want, which means all terms are mandatory. Or you can set it to a reasonable percentage, so the user would get some results even if there is no exact match for all terms.

You can also add pf (Phrase field) parameter to boost by phrases. So, black, adidas, and adidas black will be matched (if you don't have mm=100%), but 'adidas black' will be the first result as it will have the highest score.

So, you can have a query like this:

http://127.0.0.1:8080/solr/collection1/select?q=adidas+black&mm=65%&pf=YourFieldName
Emad
  • 544
  • 2
  • 6
  • Thanks for the fast reply its working fine but it is searching in the case that both words are in side by side only. For me i don't have like that i have the some products like "adidas v-neck black t-shirt" in this case its not working – Naresh Mar 31 '14 at 06:05
  • try to play with the qs parameter, or get rid of the double quotes completely, and use the mm and pf parameter as i explained – Emad Mar 31 '14 at 06:08
  • Yeah.. i tried that one also still i have same problem – Naresh Mar 31 '14 at 06:14
  • In this case, you might be able to get more help if you post your schema, and solrconfig files. – Emad Mar 31 '14 at 06:18
  • Really thank you very much Boss finally i got the solution i just combined the last two from your answer now i'm getting exact values & ASAP i'll post the complete answer. – Naresh Mar 31 '14 at 06:28
  • I have the same problem for suggestions & Spell Check also.. How can i solve that one – Naresh Apr 03 '14 at 12:51
  • Hi Dude this one is not working in the case of,I'm searching with a word "Black adidas"its giving 0 products.... why ? – Naresh Apr 14 '14 at 12:23
0

In my case its working fine...

http://127.0.0.1:8080/solr/collection1/select?q="adidas+black"&indent=true&defType=dismax&pf=YourFieldName&qs=2
Naresh
  • 681
  • 2
  • 12
  • 39