You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Kun Hong <kh...@promptu.com> on 2007/04/03 06:01:08 UTC

Can Query.toString() output be parsed to the same query?

Hi,

I am new to Lucene. I find that the output
of the Query.toString() method cannot be parsed
back to the same query. Is it true? If it is
true, I am wondering why not make the output of
Query.toString() parsable to the same query again?
Unless there is something prevent us to do so, such
as: not every query has a feasible string representation
that can be parsed to it.

I have one example here to clarify what I am talking about:
I construct a MultiPhraseQuery to search  the title field
that is equivalent to searhching "rolling stone" as a prefix.
The output of the query's toString method is

title:"rolling (stone stoned stones)"

But this string will not be parsed back to a MultiPhrase query
but instead to a PhraseQuery consisting of Terms "rolling",
"stone", "stoned" and "stones".

Thanks in advance for any answers.

Kun

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


Re: Can Query.toString() output be parsed to the same query?

Posted by Chris Hostetter <ho...@fucit.org>.
: I am new to Lucene. I find that the output
: of the Query.toString() method cannot be parsed
: back to the same query. Is it true? If it is
: true, I am wondering why not make the output of
: Query.toString() parsable to the same query again?

some of hte more simplified query classes generate a toString that is
parsable by the QueryParser -- but not all (because there are many more
types of queries then there are special markup in the QueryPArser to
denote them)

In general, no matter how robust a parser you might might write, you can
never get perfect reparsing of a Query.toString unless the "Analyzyer"
you use is extremely simplistic -- Analyzers are not required to be
transitive, ie: analysis(foo) == bar does not imply analysis(bar) == bar

(think of stemming for example)


-Hoss


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