You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Scott Smith <ss...@mainstreamdata.com> on 2011/09/16 02:30:06 UTC

Lucene->SOLR transition

I've been using lucene for a number of years.  We've now decided to move to SOLR.  I have a couple of questions.


1.       I'm used to creating Boolean queries, filter queries, term queries, etc. for lucene.  Am I right in thinking that for SOLR my only option is creating string queries (with q and fq components) for solrj?

2.       Assuming that the answer to 1 is "correct", then is there an easy way to take a lucene query (with nested Boolean queries, filter queries, etc.) and generate a SOLR query string with q and fq components?

Thanks

Scott

Re: Lucene->SOLR transition

Posted by Tomás Fernández Löbbe <to...@gmail.com>.
Hi Scott, now your queries are going to be created by a QueryParser. you
have a couple of options here, most common are LuceneQueryParser,
DismaxQueryParser and ExtendedDismaxQueryParser, but there are others. The
QueryParser will be creating all those queries you mentiones, for example,
if you are using the LuceneQueryParser and you send the query string:

field1:foo AND field2:bar

it will create a BooleanQuery with two TermQuery as clauses. The same with
more complex queries.

There are also some other QueryParsers for more specific cases. Take a look
at this class: org.apache.solr.search.QParserPlugin

You can choose and change the query parser with each request.

Local params can also be useful for you:
http://wiki.apache.org/solr/LocalParams

Regards,

Tomás

On Fri, Sep 16, 2011 at 4:25 AM, Federico Fissore <fe...@fissore.org>wrote:

> Hi
>
> Scott Smith, il 16/09/2011 02:30, ha scritto:
>
>  I've been using lucene for a number of years.  We've now decided to move
>> to SOLR.  I have a couple of questions.
>>
>>
>> 1.       I'm used to creating Boolean queries, filter queries, term
>> queries, etc. for lucene.  Am I right in thinking that for SOLR my only
>> option is creating string queries (with q and fq components) for solrj?
>>
>> 2.       Assuming that the answer to 1 is "correct", then is there an easy
>> way to take a lucene query (with nested Boolean queries, filter queries,
>> etc.) and generate a SOLR query string with q and fq components?
>>
>
>
> one other option is to build your own SearchComponent and handle additional
> parameters
>
> best regards
>
> federico
>

Re: Lucene->SOLR transition

Posted by Federico Fissore <fe...@fissore.org>.
Hi

Scott Smith, il 16/09/2011 02:30, ha scritto:
> I've been using lucene for a number of years.  We've now decided to move to SOLR.  I have a couple of questions.
>
>
> 1.       I'm used to creating Boolean queries, filter queries, term queries, etc. for lucene.  Am I right in thinking that for SOLR my only option is creating string queries (with q and fq components) for solrj?
>
> 2.       Assuming that the answer to 1 is "correct", then is there an easy way to take a lucene query (with nested Boolean queries, filter queries, etc.) and generate a SOLR query string with q and fq components?


one other option is to build your own SearchComponent and handle 
additional parameters

best regards

federico

Re: Lucene->SOLR transition

Posted by Michael Sokolov <so...@ifactory.com>.
On 9/19/2011 5:27 AM, Erik Hatcher wrote:
> On Sep 18, 2011, at 19:43 , Michael Sokolov wrote:
>
>> On 9/15/2011 8:30 PM, Scott Smith wrote:
>>> 2.       Assuming that the answer to 1 is "correct", then is there an easy way to take a lucene query (with nested Boolean queries, filter queries, etc.) and generate a SOLR query string with q and fq components?
>>>
>>>
>> I believe that Query.toString() will probably get you back something that can be parsed in turn by the traditional lucene QueryParser, thus completing the circle and returning your original Query.  But why would you want to do that?
> No, you can't rely on Query.toString() roundtripping (think stemming, for example - but many other examples that won't work that way too).
Oops - thanks for clearing that up, Erik


RE: Lucene->SOLR transition

Posted by Scott Smith <ss...@mainstreamdata.com>.
OK.  Thanks for all of the suggestions.

Cheers

Scott

-----Original Message-----
From: Erik Hatcher [mailto:erik.hatcher@gmail.com] 
Sent: Monday, September 19, 2011 3:27 AM
To: solr-user@lucene.apache.org
Subject: Re: Lucene->SOLR transition


On Sep 18, 2011, at 19:43 , Michael Sokolov wrote:

> On 9/15/2011 8:30 PM, Scott Smith wrote:
>> 
>> 2.       Assuming that the answer to 1 is "correct", then is there an easy way to take a lucene query (with nested Boolean queries, filter queries, etc.) and generate a SOLR query string with q and fq components?
>> 
>> 
> I believe that Query.toString() will probably get you back something that can be parsed in turn by the traditional lucene QueryParser, thus completing the circle and returning your original Query.  But why would you want to do that?

No, you can't rely on Query.toString() roundtripping (think stemming, for example - but many other examples that won't work that way too).

What you can do, since you know Lucene's API well, is write a QParser(Plugin) that takes request parameters as strings and generates the Query from that like you are now with your Lucene app.

	Erik


Re: Lucene->SOLR transition

Posted by Erik Hatcher <er...@gmail.com>.
On Sep 18, 2011, at 19:43 , Michael Sokolov wrote:

> On 9/15/2011 8:30 PM, Scott Smith wrote:
>> 
>> 2.       Assuming that the answer to 1 is "correct", then is there an easy way to take a lucene query (with nested Boolean queries, filter queries, etc.) and generate a SOLR query string with q and fq components?
>> 
>> 
> I believe that Query.toString() will probably get you back something that can be parsed in turn by the traditional lucene QueryParser, thus completing the circle and returning your original Query.  But why would you want to do that?

No, you can't rely on Query.toString() roundtripping (think stemming, for example - but many other examples that won't work that way too).

What you can do, since you know Lucene's API well, is write a QParser(Plugin) that takes request parameters as strings and generates the Query from that like you are now with your Lucene app.

	Erik


Re: Lucene->SOLR transition

Posted by Michael Sokolov <so...@ifactory.com>.
On 9/15/2011 8:30 PM, Scott Smith wrote:
>
> 2.       Assuming that the answer to 1 is "correct", then is there an easy way to take a lucene query (with nested Boolean queries, filter queries, etc.) and generate a SOLR query string with q and fq components?
>
>
I believe that Query.toString() will probably get you back something 
that can be parsed in turn by the traditional lucene QueryParser, thus 
completing the circle and returning your original Query.  But why would 
you want to do that?

-Mike