query about Query.ToString()

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

query about Query.ToString()

Aaron Schon
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?



Reply | Threaded
Open this post in threaded view
|

Re: query about Query.ToString()

Mark Miller-3
Aaron Schon 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?
>
>
>      
>  
For some queries its possible - the docs for Query say impls should
attempt to be parsable by the QueryParser - but in practice it's not
always the case. So you can't reallly count on it across the board.

By the way, these questions are best sent to java-user rather than general.

--
- Mark

http://www.lucidimagination.com



Reply | Threaded
Open this post in threaded view
|

Re: query about Query.ToString()

Aaron Schon
Mark, Thanks for responding and the tip about java-user.
So should I be able to do something like Queryparser.parse(q.ToString())? //Query q

 


----- Original Message ----
From: Mark Miller <[hidden email]>
To: [hidden email]
Sent: Wed, February 17, 2010 10:33:04 AM
Subject: Re: query about Query.ToString()

Aaron Schon 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?
>
>
>     

For some queries its possible - the docs for Query say impls should
attempt to be parsable by the QueryParser - but in practice it's not
always the case. So you can't reallly count on it across the board.

By the way, these questions are best sent to java-user rather than general.

--
- Mark

http://www.lucidimagination.com