Vincent,

Look at Solr's fq (filter query) capability.  You'll likely want to put your 
restricting query in an fq parameter from your search client.

If your restricting query is a simple TermQuery, have a look at the various 
built-in query parsers in Solr.  On trunk you can do this: &fq={!term 
f=restriction_field}value, or in other versions look at the raw or field query 
parsers.

Or you can use Lucene query syntax in an fq parameter and make more 
sophisticated expressions (at the risk of query parsing exceptions, of course).

        Erik



On Feb 17, 2011, at 09:09 , Vincent Cautaerts wrote:

> Hi,
> 
> I'm porting/upgrading a project from Lucene to Solr.
> 
> In Lucene, I was using the user-provided Lucene query string, and I did
> complete it to implement access restriction, based on fields saved in the
> index:
> 
> Query userQ=... // query from user
> Query restrictQ=.. // implement restrictions
> Query finalQ=new BooleanQuery();
> finalQ.add(userQ,BooleanClause.Occur.MUST);
> finalQ.add(restrictQ,BooleanClause.Occur.MUST);
> 
> Searching on 'finalQ' gives only the results which can be shown to the user.
> 
> 
> Since Solr doesn't have programmatically build queries, how can I do
> something equivalent?
> 
> Do we always have to build strings to make a query in SolR? Is there really
> no equivalent to the Lucene API to build a query, using BooleanQuery,
> TermQuery,... ?
> 
> Thanks for your help!

Reply via email to