You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by Chris Hostetter <ho...@fucit.org> on 2008/11/03 19:32:37 UTC
Re: Query syntax improvement: Add one boundary range query syntax
: Currently, lucene query syntax supports range query like foo:[a TO b]. I
: didn't find a way to support one boundary range. (Or did I miss something?)
FWIW: the SolrQueryParser (which subclasses the Lucene QueryParser)
accomplishes this by treating '*' as special values.
users that want similar behavior with Lucene should be able to get it
fairly trivially with something like...
QueryParser qp = new QueryParser("foo", analyzer) {
protected Query newRangeQuery(String f, String a, String b, boolean i) {
return super.newRangeQuery(f, "*".equals(a) ? null : a,
"*".equals(b) ? null : b, i);
}
}
but commiting a chacne like that to the existing Lucene QueryParser might
break things for some people (although it seems unlikely)
-Hoss
---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org
Re: Query syntax improvement: Add one boundary range query syntax
Posted by Andrew Zhang <zh...@gmail.com>.
Good suggestion! Thanks a lot, Chris.
On Tue, Nov 4, 2008 at 2:32 AM, Chris Hostetter <ho...@fucit.org>wrote:
>
> : Currently, lucene query syntax supports range query like foo:[a TO b]. I
> : didn't find a way to support one boundary range. (Or did I miss
> something?)
>
> FWIW: the SolrQueryParser (which subclasses the Lucene QueryParser)
> accomplishes this by treating '*' as special values.
>
> users that want similar behavior with Lucene should be able to get it
> fairly trivially with something like...
>
> QueryParser qp = new QueryParser("foo", analyzer) {
> protected Query newRangeQuery(String f, String a, String b, boolean i) {
> return super.newRangeQuery(f, "*".equals(a) ? null : a,
> "*".equals(b) ? null : b, i);
> }
> }
>
>
> but commiting a chacne like that to the existing Lucene QueryParser might
> break things for some people (although it seems unlikely)
>
>
>
> -Hoss
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-dev-help@lucene.apache.org
>
>
--
Best regards,
Andrew Zhang
db4o - database for Android: www.db4o.com
http://zhanghuangzhu.blogspot.com/