I've also just noticed that QueryParsing is not in the SolrJ API. It's in one 
of the other Solr jar dependencies.

I'm beginning to think that maybe the best approach it to write a query string 
generator which can generate strings of the form: 

q={!lucene q.op=AND df=text}myfield:foo +bar -baz

Then just set this on a SolrQuery instance and send it over the wire. It not 
the kind of string you'd want an end user to have to type out.

-----Original Message-----
From: Ahmet Arslan [mailto:iori...@yahoo.com] 
Sent: 07 January 2010 17:38
To: solr-user@lucene.apache.org
Subject: Re: SolJ and query parameters



--- On Thu, 1/7/10, Jon Poulton <jon.poul...@vyre.com> wrote:

> From: Jon Poulton <jon.poul...@vyre.com>
> Subject: SolJ and query parameters
> To: "'solr-user@lucene.apache.org'" <solr-user@lucene.apache.org>
> Date: Thursday, January 7, 2010, 7:25 PM
> Hi there,
> I'm trying to understand how the query syntax specified on
> the Solr Wiki ( http://wiki.apache.org/solr/SolrQuerySyntax ) fits in
> with the usage of the SolJ class SolrQuery. There are not
> too many examples of usage to be found.
> 
> For example. Say I wanted to replicate the following query
> using SolrQuery.
> 
> q={!lucene q.op=AND df=text}myfield:foo +bar -baz

Whole string is the value of the parameter q.

SolrQuery.setQuery("{!lucene q.op=AND df=text}myfield:foo +bar -baz");

> How would I do it so that q.op was set to "OR" instead of
> "AND"? There is no method I can see on SolrQuery to set
> q.op, only a "query string", which is presumably in this
> case is the text "+bar -baz", as the rest can be specified
> by calling set methods on SolrQuery.

if you want to set q.op to AND you can use SolrQuery.set(QueryParsing.OP,"AND");

hope this helps.


      

Reply via email to