Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Lucene: Java-User

Store a query in a database for later use

 

 

Lucene java-user RSS feed   Index | Next | Previous | View Threaded


google at suncom

May 17, 2012, 12:53 PM

Post #1 of 4 (219 views)
Permalink
Store a query in a database for later use

Hi,

I want to store a query for later use in a database, like:

1. queryToPersist = booleanQuery.toString();
2. store it to the db, go fishing, retrieve it
3. Query query = Query.parseString(queryToPersist)

The method Query.parseString does not exist. Is there a way to do something similar?


jej2003 at gmail

May 17, 2012, 1:23 PM

Post #2 of 4 (214 views)
Permalink
Re: Store a query in a database for later use [In reply to]

I think you want to have a look at the QueryParser classes. Not sure
which you're using to start with but probably the default QueryParser
should suffice.

On Thu, May 17, 2012 at 3:53 PM, Stefan Undorf <google [at] suncom> wrote:
> Hi,
>
> I want to store a query for later use in a database, like:
>
> 1. queryToPersist = booleanQuery.toString();
> 2. store it to the db, go fishing, retrieve it
> 3. Query query = Query.parseString(queryToPersist)
>
> The method Query.parseString does not exist. Is there a way to do something similar?
>

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe [at] lucene
For additional commands, e-mail: java-user-help [at] lucene


trejkaz at trypticon

May 17, 2012, 2:13 PM

Post #3 of 4 (215 views)
Permalink
Re: Store a query in a database for later use [In reply to]

On Fri, May 18, 2012 at 6:23 AM, Jamie Johnson <jej2003 [at] gmail> wrote:
> I think you want to have a look at the QueryParser classes.  Not sure
> which you're using to start with but probably the default QueryParser
> should suffice.

There are (at least) two catches though:

1. The semantics of a QueryParser might change over time. For
instance, today you might do "white b*" and it is a normal phrase
query. This could gets saved off and in a later version of Lucene, the
QueryParser is updated to parse it as a wildcard phrase query.

2. toString() doesn't always generate a query that the QueryParser can parse.

Lucene Query objects do implement Serializable though so they can be
serialised into a byte array. I do wonder how safe it is to do it
though (if I serialise one from a really early version is it expected
to serialise back in a much later version or does the Lucene backwards
compatibility policy not cover serialisation?)

TX

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe [at] lucene
For additional commands, e-mail: java-user-help [at] lucene


iorixxx at yahoo

May 18, 2012, 1:05 AM

Post #4 of 4 (215 views)
Permalink
Re: Store a query in a database for later use [In reply to]

> 2. toString() doesn't always generate a query that the
> QueryParser can parse.

I remember similar discussion, I think Xml-Query-Parser is more suitable for this use case.

http://www.lucidimagination.com/blog/2009/02/22/exploring-query-parsers/


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe [at] lucene
For additional commands, e-mail: java-user-help [at] lucene

Lucene java-user RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.