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

Mailing List Archive: Lucene: Java-User

Query.toString() and QueryParser.parse()

 

 

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


loesh at kth

Aug 22, 2007, 3:34 AM

Post #1 of 3 (1839 views)
Permalink
Query.toString() and QueryParser.parse()

Hi, I am wondering if QueryParser.parse(...) is supposed to be able to
recreate any given query using something like:

Query query = //creating query somehow.
Queryparser qp = //creatign a query parser

String queryString = query.toString();

Query parsed = qp.parse(queryString);
String parsedString = parsed.toString();

boolean equals = parsedString().equals(queryString);

Maybe not the clearest of questions. but should "equals" in the above
example allways be true for any Query?

Sincerley,
Fredrik Ståhl


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


erik at ehatchersolutions

Aug 22, 2007, 3:49 AM

Post #2 of 3 (1787 views)
Permalink
Re: Query.toString() and QueryParser.parse() [In reply to]

On Aug 22, 2007, at 6:34 AM, loesh wrote:
> Query parsed = qp.parse(queryString);
> String parsedString = parsed.toString();
>
> boolean equals = parsedString().equals(queryString);
>
> Maybe not the clearest of questions. but should "equals" in the
> above example allways be true for any Query?

No, that never has been a design goal of Query.toString(), and there
many cases that it fails. QueryParser only supports a fraction of
the Query subclasses out there, so any Query subclass it does not
support, of course, will fail to parse as you're expecting.

I understand the benefit such a feature would have, though.

Erik


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


loesh at kth

Aug 22, 2007, 3:55 AM

Post #3 of 3 (1761 views)
Permalink
Re: Query.toString() and QueryParser.parse() [In reply to]

Erik Hatcher wrote:
>
> On Aug 22, 2007, at 6:34 AM, loesh wrote:
>> Query parsed = qp.parse(queryString);
>> String parsedString = parsed.toString();
>>
>> boolean equals = parsedString().equals(queryString);
>>
>> Maybe not the clearest of questions. but should "equals" in the above
>> example allways be true for any Query?
>
> No, that never has been a design goal of Query.toString(), and there
> many cases that it fails. QueryParser only supports a fraction of the
> Query subclasses out there, so any Query subclass it does not support,
> of course, will fail to parse as you're expecting.
>
> I understand the benefit such a feature would have, though.
>
> Erik
>
>
Ok, thanks for the fast reply. I kind of figured it was not supposed to
be that way but it would have some benefits.


---------------------------------------------------------------------
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.