By rolf van de krol on
I try to query Apache Solr to generate some search results.
$results = apachesolr_search_execute('some keywords','tid:1','','my/base/path',0,'mymodule');
this works perfectly well. The problems arise when i try to do this:
$results = apachesolr_search_execute('some keywords','tid:1 (tid:2 OR tid:3)','','my/base/path',0,'mymodule');
Somewhere I probably missed something, but to me, this should mean: give me all the nodes matching:
- some keywords
- assigned to term with tid = 1
- assigned to term with tid = 2 or assigned to term with tid = 3
It doesn't work like this. My question is: how does it work? It it possible to query solr with this? And if yes: how?
Thanks in advance for your help.
Comments
this doesn't work either
I'm trying to solve something similar, I thought this would work, but does not, nor does char encoding the plus (&43;)
would require some extra work
After some more digging, found that solr is capable of searching with a param like fq=(tid:2+OR+tid:3), but at present, the Solr_Base_Query class doesn't like a filter passed in like that. It only allows range queries through, otherwise it wraps it in quotes. It also wants to set the filter like name:value, but we want to set it like (name:value+OR+name:value) ... a solution that would require some extra work.
From the Solr_Base_Query (in the apachesolr mod directory)
See the apachesolr_nodeacess
See the apachesolr_nodeacess module under the contrib/ dir for its construction of an OR fq parameter.
---
Work: BioRAFT
It seems it makes the query
It seems it makes the query tid:1 OR tid:2
But how to implement tid:3 (tid:1 OR tid:2)?
These do not work:
To OR join two filters
To OR join two filters, what you want to do is:
Thank you!
Thanks for this, it was helpful - although in D7 now you use the SolrFilterSubQuery class and $query->addFilterSubQuery to attach them to your query, but the method was otherwise identical.
Have I helped you? Consider buying me a beer.
And how to make range filter
And how to make range filter say like from 1000 to 2000 for example? I gotta hard time how to do this.
nvrmind, got
nvrmind, got it