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 ?
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
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