I'm currently working on solr, in which to create a connection I need to write
http://localhost:8983/solr/select?q=category_name:cat1%20_query_:"{!dismax%20qf=category_name%20v=cat2}"
where cat1 and cat2 are the categories in which I want my product to be, i.e. All those products that have these 2 categories.
I get accurate results using this, I can find how to write the same thing in Java using SolrJ api
Wat i did
String myQuery = ""; myQuery += "category_name:"; myQuery += categoryNames.get(0); myQuery += "%20_query_:\"{!dismax%20qf=category_name%20v="; myQuery += categoryNames.get(1); myQuery += "}\""; query.setQuery(myQuery);
it does not give soln, solr gives an error
now according to 1st ans page
SolrQuery query = new SolrQuery(); query.setQuery("category_name:" + categoryNames.get(0)); String join = ""; join += "{!dismax&qf=category_name&v="; join += categoryNames.get(1); join += "}"; query.setParam("_query_", join); QueryResponse response = solr.query(query);
better, but it still doesnβt work, adds β&β which I donβt want, since the output is wrong this wat goes to solr for processing here the results come only based on βcat1β and not AND both
q=category_name:cat1&_query_={!dismax%26qf%3Dcategory_name%26v%3Dcat2}
3rd, tried the wat page suggested in the last answer, fails this wat goes to solr for processing here they work as an OR operator, not AND
q=category_name:cat1+_query_:"{!dismax+qf%3Dcategory_name+v%3Dcat2}"
PS: I need to find a solution on how to write myQuery, pls help stuck in it
Finally he decided inested + = "AND query: \" {! dismax qf = category_name v = "; is the solution to my problem
Now the request is being processed! Thanks