lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Anuj Shah <anujshahw...@gmail.com>
Subject Re: Syntax for Numeric Range
Date Fri, 04 Feb 2011 15:39:00 GMT
In my case the query engine is very generic and, along side the QueryParser,
doesn't know about the fields. So I can't decide whether a TermRangeQuery
and a NumericRangeQuery.

How about a syntax like:

> numericfield:[{1 TO 10}]
>

Using Luke this seems to parse into a TermRangeQuery with the { } in place.
It should be possible to pick this case out in newRangeQuery and construct a
NumericRangeQuery instead.

Would you know if this is likely to cause other unwanted effects when used
with more complicated query strings?

Thanks

Anuj


On 4 February 2011 15:02, Uwe Schindler <uwe@thetaphi.de> wrote:

> You have everything you need to implement this. This is much easier to
> change the syntax.
>
> -----
> Uwe Schindler
> H.-H.-Meier-Allee 63, D-28213 Bremen
> http://www.thetaphi.de
> eMail: uwe@thetaphi.de
>
> > -----Original Message-----
> > From: Anuj Shah [mailto:anujshahwork@gmail.com]
> > Sent: Friday, February 04, 2011 2:53 PM
> > To: java-user@lucene.apache.org
> > Subject: Re: Syntax for Numeric Range
> >
> > Hi,
> >
> > I see why the existing syntax cannot be used to automatically generate a
> > NumericRange. But, is it possible to extend the QueryParser to include
> > additional syntax for a numeric range. e.g.
> >
> > numericfield:[1;10]
> > >
> >
> > The user can be trained to use this syntax for certain fields (i.e those
> that I
> > know are indexed as NumericField)
> >
> > Thanks
> >
> > Anuj
> >
> >
> >
> >
> >
> > On 3 February 2011 16:22, Uwe Schindler <uwe@thetaphi.de> wrote:
> >
> > > Hi Anuj,
> > >
> > > You have to subclass QueryParser and override newRangeQuery() to parse
> > > yourself. Automatic parsing is impossible, because QueryParser does
> > > not know (in contrast to Apache Solr) which fields have which type
> > > (Lucene has no field schema).
> > >
> > > Example how to do this:
> > >
> > > http://mail-archives.apache.org/mod_mbox/lucene-java-
> > user/200910.mbox/
> > > %3CBLU
> > > 140-W22F12E1C9AC650580E9852D0BE0@phx.gbl%3E<http://mail-
> > archives.apach
> > > e.org/mod_mbox/lucene-java-user/200910.mbox/%3CBLU%0A140-
> > W22F12E1C9AC6
> > > 50580E9852D0BE0@phx.gbl%3E>
> > >
> > > Uwe
> > >
> > > -----
> > > Uwe Schindler
> > > H.-H.-Meier-Allee 63, D-28213 Bremen
> > > http://www.thetaphi.de
> > > eMail: uwe@thetaphi.de
> > >
> > >
> > > > -----Original Message-----
> > > > From: Anuj Shah [mailto:anujshahwork@gmail.com]
> > > > Sent: Thursday, February 03, 2011 4:50 PM
> > > > To: java-user@lucene.apache.org
> > > > Subject: Syntax for Numeric Range
> > > >
> > > > Is there a query syntax for specifying a numeric range for a field
> > > indexed
> > > as a
> > > > NumericField.
> > > >
> > > > I've tried
> > > >
> > > > numericfield:[0 TO 10]
> > > > >
> > > >
> > > > But it is parsed as a TermRangeQuery and not a NumericRangeQuery.
> > > >
> > > > Many thanks
> > > >
> > > > Anuj
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> > > For additional commands, e-mail: java-user-help@lucene.apache.org
> > >
> > >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message