I recently had the same need, for a utility to get me from the Query toString() 
output back to the Java code to construct that specific query in Lucene.  The 
reason for my interest is that our query syntax differs significantly from the 
standard Lucene query syntax, so having something like this would be useful.

If I build it, I'll post it (but I'm currently doing this all by hand so I can 
post some questions to this list, so I probably won't).

  Mike


-----Original Message-----
From: java-user-return-45057-michael.j.goddard=saic....@lucene.apache.org on 
behalf of Erick Erickson
Sent: Wed 2/17/2010 1:55 PM
To: java-user@lucene.apache.org
Subject: Re: Query about Query.ToString()
 
Well, Query *does* implement the Serializable interface, so that
might work. WARNING: I haven't personally used the Serializable
interface on Query, so I have no real clue whether it's applicable!

Taking the results of query.toString() and pumping it back through
the parser is not guaranteed to produce an equivalent query though.

But if you're creating a library of queries, why not just code up the
queries
as strings and store/reuse those?

I'd think about forming a query that I can send through the query parsing,
then storing that string for later reuse (i.e. the string you parsed). This
has
problems if you're constructing the query programatically (say assembling
a BooleanQuery in the lucene code) though.

not much help I know
Erick


On Wed, Feb 17, 2010 at 1:44 PM, Aaron Schon <aaron_sc...@yahoo.com> wrote:

> Hi all, I know that persisting a Lucene query by query ToString() method.
> Is there any way of reconstructing the query from the string itself?
> The usecase is that I will be storing a library of queries as strings and
> load the appropriate query (from the string) based on some conditions.
>
> Is this possible? Could you share a code snippet?
>
> p.s. apologies for the double posting (I had asked this on Lucene general
> and was asked to ask here instead)
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org
> For additional commands, e-mail: java-user-h...@lucene.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org
For additional commands, e-mail: java-user-h...@lucene.apache.org

Reply via email to