Re: Query#rewrite Question

2004-11-11 Thread Erik Hatcher
On Nov 10, 2004, at 9:51 PM, Satoshi Hasegawa wrote:
Our program accepts input in the form of Lucene query syntax from the 
user,
but we wish to perform additional tasks such as thesaurus expansion. 
So I
want to manipulate the Query object that results from parsing.
You may want to consider using an Analyzer to expand queries rather 
than manipulating the query object itself.

My question is, is the result of the Query#rewrite method guaranteed 
to be
either a TermQuery, a PhraseQuery, or a BooleanQuery, and if it is a
BooleanQuery, do all the constituent clauses also reduce to one of the 
above
three classes?
No.  For example, look at the SpanQuery family.  These do no explicit 
rewriting and thus are left as themselves.

 If not, what if the original Query object was the one that
was obtained from QueryParser#parse method? Can I assume the above in 
this
restricted case?

I experimented with the current version, and the above seems to be 
positive
in this version; I'm asking if this could change in the future. Thank 
you.
I think we'll see QueryParser, or at least more sophisticated versions 
of it, emerge that support SpanQuery's.  In fact, in our book, I 
created a subclas of QueryParser that overrides getFieldQuery and 
returns a SpanNearQuery in order to achieve ordered phrase searching.

Erik
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: Query#rewrite Question

2004-11-11 Thread Paul Elschot

On Thursday 11 November 2004 03:51, Satoshi Hasegawa wrote:
 Hello,
 
 Our program accepts input in the form of Lucene query syntax from the user, 
 but we wish to perform additional tasks such as thesaurus expansion. So I 
 want to manipulate the Query object that results from parsing.
 
 My question is, is the result of the Query#rewrite method guaranteed to be 
 either a TermQuery, a PhraseQuery, or a BooleanQuery, and if it is a 
 BooleanQuery, do all the constituent clauses also reduce to one of the above 
 three classes? If not, what if the original Query object was the one that 
 was obtained from QueryParser#parse method? Can I assume the above in this 
 restricted case?

 I experimented with the current version, and the above seems to be positive 
 in this version; I'm asking if this could change in the future. Thank you. 
 
In general, a Query should either rewrite to another query, or provide a
Weight. During search, the Weight then provides a Scorer to score the docs.

The only other type of query currently available is SpanQuery, which is
a generalization of PhraseQuery. It does not rewrite and provides a Weight.

However, the current QueryParser does not have support for SpanQuery.
So, as long as the QueryParser does not support more than the current types
of queries, and you only use the QueryParser to obtain queries, all the
constituent clauses will reduce as you indicate above.

SpanQuery could be useful for thesaurus expansion. The generalization
it provides is that it allows nested distance queries. For example, in:
word1 word2~2
word2 can expanded to:
word2 or word3 word4~4
leading to a query that is not supported by the current QueryParser:
word1 (word 2 or word3 word4~4)~2

SpanQueries can also enforce an order on the matching subqueries,
but that is difficult to express in the current query syntax.

Regards,
Paul Elschot


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Query#rewrite Question

2004-11-11 Thread Satoshi Hasegawa
Thank you, Erik and Paul. I'm not sure what SpanQuery is, but anyway we've 
decided to freeze the version of Lucene we use. 

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Query#rewrite Question

2004-11-10 Thread Satoshi Hasegawa
Hello,

Our program accepts input in the form of Lucene query syntax from the user, 
but we wish to perform additional tasks such as thesaurus expansion. So I 
want to manipulate the Query object that results from parsing.

My question is, is the result of the Query#rewrite method guaranteed to be 
either a TermQuery, a PhraseQuery, or a BooleanQuery, and if it is a 
BooleanQuery, do all the constituent clauses also reduce to one of the above 
three classes? If not, what if the original Query object was the one that 
was obtained from QueryParser#parse method? Can I assume the above in this 
restricted case?

I experimented with the current version, and the above seems to be positive 
in this version; I'm asking if this could change in the future. Thank you.