: query something like
: 
: 
http://localhost:8983/solr/select?q=(category:lcd+OR+category:led+OR+category:plasma)+AND+(manufacture:sony+OR+manufacture:samsung+OR+manufacture:apple)&facet.field=category&facet.field=manufacture&fl=id&mm=2

Here's an example of something similar using the Solr 4.3 example data...

http://localhost:8983/solr/collection1/select?debugQuery=true&q=%2B{!dismax+df%3Dfeatures+mm%3D2+v%3D%24features}+%2B{!dismax+df%3Dcat+mm%3D2+v%3D%24cat}+&wt=xml&indent=true&cat=electronics+connector+XXXX&features=power+ipod+YYYY

the important (un url encoded) params here are...

  q = +{!dismax df=features mm=2 v=$features} +{!dismax df=cat mm=2 v=$cat} 
  features = power ipod YYYY
  cat = electronics connector XXXX

This takes advantage of the fact that the (default) "lucene" parser in 
solr can understand the "{!parser}" syntax to create subclauses using 
other parsers -- but one thing to watch out for is that if your entire 
query starts with "{!dismax}..." then it's going to try and use the dismax 
parser for the whole thing, so this won't do what you expect...

  q = {!dismax df=features mm=2 v=$features} AND {!dismax df=cat mm=2 v=$cat}

...but this will...

  q = ({!dismax df=features mm=2 v=$features} AND {!dismax df=cat mm=2 v=$cat})
  
This is a realtively new feature of the solr, in older versions you would 
need to use the _query_ parsing trick...

  q = _query_:"{!dismax df=features mm=2 v=$features}" AND _query_:"{!dismax 
df=cat mm=2 v=$cat}"


The important thing to remeber about all of this though is that it really 
doesn't matter unless you truly care about getting scoring from this 
resulting BooleanQuery based on the two sub-queries ... if all you really 
care about is *filtering* a set of documents bsaed on these two criteria, 
it's much simpler (and typically more efficient) to use filter queries...

  q = *:*
 fq = {!dismax df=features mm=2}power ipod YYYY
 fq = {!dismax df=cat mm=2}electronics connector XXXX



-Hoss

Reply via email to