lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Erik Hatcher <e...@ehatchersolutions.com>
Subject Query.toString refactoring
Date Thu, 09 Dec 2004 13:34:44 GMT
First let me demonstrate an issue.  I'm currently using QueryParser 
with AND as the default operator for one type of user query.  For 
another type of user query I create an OR'd BooleanQuery 
programatically.

I want all queries, regardless of how they were created, to be 
converted back into a parsable expression resulting in the same Query 
when parsed again (ignoring any analyzer issues at this point).  For a 
programmatically created BooleanQuery for "term1 OR term2", the 
toString method returns:

	term1 term2

This, of course, when parsed again using AND as the default operator, 
completely changes the query.

My first proposal is to change BooleanQuery.toString() to always put " 
OR " between terms that are not required or prohibited.  Any objections 
to this change?

My second proposal, and this relates to a custom query parser I'm 
working on, is to separate the conversion of a Query to a String 
completely from the Query class itself.  I envision some type of 
abstract factory mechanism, with the default implementation being the 
existing (mostly QueryParser compatible) format.  Query.toString() 
would delegate to the formatter factory.  The formatting implementation 
would be pluggable to allow other custom query expression formats to be 
generated from any Query instance.

I haven't fleshed out the exact design yet - I'm soliciting ideas for 
this effort.  Thoughts?

Thanks,
	Erik


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


Mime
View raw message