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 Nilesh Bansal <ni...@gmail.com> on 2007/08/11 22:27:05 UTC

Range queries in Lucene - numerical or lexicographical

Hi all,

Lucene query parser synax page
(http://lucene.apache.org/java/docs/queryparsersyntax.html) provides
the following two examples of range query:
mod_date:[20020101 TO 20030101]
and
title:{Aida TO Carmen}

Now my question is, numerically 10 is greater than 2, but in
string-only comparison 2 is greater than 10. So if I search for
field:[10 TO 30]
will a document with field=2 will be in result or not.

And if I search for a string field,
field:[AA TO CC]
will document with field="B" will be in result or not.

The semantics of range is not clear (numerical or lexicographical)
from the documentation.

thanks
Nilesh

-- 
Nilesh Bansal.
http://queens.db.toronto.edu/~nilesh/

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


Re: Range queries in Lucene - numerical or lexicographical

Posted by Chris Hostetter <ho...@fucit.org>.
: Subject: Re: Range queries in Lucene - numerical or lexicographical
:
: Thanks. Probably this should be mentioned on the documentation page.

it does say right above the "date" example: "....  Sorting is done
lexicographically."

(Admitedly I'm not sure why the word "Sorting" is used in that sentence,
but it should make it clear that it's a lexicographical comparison)

patches to improve documentation are always appreciated!




-Hoss


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


Re: Range queries in Lucene - numerical or lexicographical

Posted by Erick Erickson <er...@gmail.com>.
Uhhhh, because I didn't write the code? You can always contribute a patch.

On 8/13/07, Mohammad Norouzi <mn...@gmail.com> wrote:
>
> Thanks Erick but unfortunately NumberTools works only with long primitive
> type I am wondering why you didn't put some method for double and float.
>
>
>
> On 8/13/07, Nilesh Bansal <ni...@gmail.com> wrote:
> >
> > Thanks. Probably this should be mentioned on the documentation page.
> >
> > -Nilesh
> >
> > On 8/12/07, Erick Erickson <er...@gmail.com> wrote:
> > > As has been discussed several times, Lucene is a string-only engine,
> and
> > > has no native understanding of numerical values. You have to normalize
> > > them for string searches. See NumberTools.
> > >
> > > Best
> > > Erick
> > >
> > > On 8/11/07, Nilesh Bansal <ni...@gmail.com> wrote:
> > > >
> > > > Hi all,
> > > >
> > > > Lucene query parser synax page
> > > > (http://lucene.apache.org/java/docs/queryparsersyntax.html) provides
> > > > the following two examples of range query:
> > > > mod_date:[20020101 TO 20030101]
> > > > and
> > > > title:{Aida TO Carmen}
> > > >
> > > > Now my question is, numerically 10 is greater than 2, but in
> > > > string-only comparison 2 is greater than 10. So if I search for
> > > > field:[10 TO 30]
> > > > will a document with field=2 will be in result or not.
> > > >
> > > > And if I search for a string field,
> > > > field:[AA TO CC]
> > > > will document with field="B" will be in result or not.
> > > >
> > > > The semantics of range is not clear (numerical or lexicographical)
> > > > from the documentation.
> > > >
> > > > thanks
> > > > Nilesh
> > > >
> > > > --
> > > > Nilesh Bansal.
> > > > http://queens.db.toronto.edu/~nilesh/
> > > >
> > > >
> ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> > > > For additional commands, e-mail: java-user-help@lucene.apache.org
> > > >
> > > >
> > >
> >
> >
> > --
> > Nilesh Bansal.
> > http://queens.db.toronto.edu/~nilesh/
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> > For additional commands, e-mail: java-user-help@lucene.apache.org
> >
> >
>
>
> --
> Regards,
> Mohammad
> --------------------------
> see my blog: http://brainable.blogspot.com/
> another in Persian: http://fekre-motefavet.blogspot.com/
>

Re: Range queries in Lucene - numerical or lexicographical

Posted by Mohammad Norouzi <mn...@gmail.com>.
Thanks Erick but unfortunately NumberTools works only with long primitive
type I am wondering why you didn't put some method for double and float.



On 8/13/07, Nilesh Bansal <ni...@gmail.com> wrote:
>
> Thanks. Probably this should be mentioned on the documentation page.
>
> -Nilesh
>
> On 8/12/07, Erick Erickson <er...@gmail.com> wrote:
> > As has been discussed several times, Lucene is a string-only engine, and
> > has no native understanding of numerical values. You have to normalize
> > them for string searches. See NumberTools.
> >
> > Best
> > Erick
> >
> > On 8/11/07, Nilesh Bansal <ni...@gmail.com> wrote:
> > >
> > > Hi all,
> > >
> > > Lucene query parser synax page
> > > (http://lucene.apache.org/java/docs/queryparsersyntax.html) provides
> > > the following two examples of range query:
> > > mod_date:[20020101 TO 20030101]
> > > and
> > > title:{Aida TO Carmen}
> > >
> > > Now my question is, numerically 10 is greater than 2, but in
> > > string-only comparison 2 is greater than 10. So if I search for
> > > field:[10 TO 30]
> > > will a document with field=2 will be in result or not.
> > >
> > > And if I search for a string field,
> > > field:[AA TO CC]
> > > will document with field="B" will be in result or not.
> > >
> > > The semantics of range is not clear (numerical or lexicographical)
> > > from the documentation.
> > >
> > > thanks
> > > Nilesh
> > >
> > > --
> > > Nilesh Bansal.
> > > http://queens.db.toronto.edu/~nilesh/
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> > > For additional commands, e-mail: java-user-help@lucene.apache.org
> > >
> > >
> >
>
>
> --
> Nilesh Bansal.
> http://queens.db.toronto.edu/~nilesh/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>


-- 
Regards,
Mohammad
--------------------------
see my blog: http://brainable.blogspot.com/
another in Persian: http://fekre-motefavet.blogspot.com/

Re: Range queries in Lucene - numerical or lexicographical

Posted by Nilesh Bansal <ni...@gmail.com>.
Thanks. Probably this should be mentioned on the documentation page.

-Nilesh

On 8/12/07, Erick Erickson <er...@gmail.com> wrote:
> As has been discussed several times, Lucene is a string-only engine, and
> has no native understanding of numerical values. You have to normalize
> them for string searches. See NumberTools.
>
> Best
> Erick
>
> On 8/11/07, Nilesh Bansal <ni...@gmail.com> wrote:
> >
> > Hi all,
> >
> > Lucene query parser synax page
> > (http://lucene.apache.org/java/docs/queryparsersyntax.html) provides
> > the following two examples of range query:
> > mod_date:[20020101 TO 20030101]
> > and
> > title:{Aida TO Carmen}
> >
> > Now my question is, numerically 10 is greater than 2, but in
> > string-only comparison 2 is greater than 10. So if I search for
> > field:[10 TO 30]
> > will a document with field=2 will be in result or not.
> >
> > And if I search for a string field,
> > field:[AA TO CC]
> > will document with field="B" will be in result or not.
> >
> > The semantics of range is not clear (numerical or lexicographical)
> > from the documentation.
> >
> > thanks
> > Nilesh
> >
> > --
> > Nilesh Bansal.
> > http://queens.db.toronto.edu/~nilesh/
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> > For additional commands, e-mail: java-user-help@lucene.apache.org
> >
> >
>


-- 
Nilesh Bansal.
http://queens.db.toronto.edu/~nilesh/

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


Re: Range queries in Lucene - numerical or lexicographical

Posted by Erick Erickson <er...@gmail.com>.
As has been discussed several times, Lucene is a string-only engine, and
has no native understanding of numerical values. You have to normalize
them for string searches. See NumberTools.

Best
Erick

On 8/11/07, Nilesh Bansal <ni...@gmail.com> wrote:
>
> Hi all,
>
> Lucene query parser synax page
> (http://lucene.apache.org/java/docs/queryparsersyntax.html) provides
> the following two examples of range query:
> mod_date:[20020101 TO 20030101]
> and
> title:{Aida TO Carmen}
>
> Now my question is, numerically 10 is greater than 2, but in
> string-only comparison 2 is greater than 10. So if I search for
> field:[10 TO 30]
> will a document with field=2 will be in result or not.
>
> And if I search for a string field,
> field:[AA TO CC]
> will document with field="B" will be in result or not.
>
> The semantics of range is not clear (numerical or lexicographical)
> from the documentation.
>
> thanks
> Nilesh
>
> --
> Nilesh Bansal.
> http://queens.db.toronto.edu/~nilesh/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>