Mailing List Archive

Searching greater than/less than
Can I use lucene to search greater than / less than a value in the field? I
have a field in the document that function as a score. I would need to be
able to search the index + the option having to say a field > 50

Regards,

--
Victor Hadianto

--
To unsubscribe, e-mail: <mailto:lucene-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:lucene-user-help@jakarta.apache.org>
Re: Searching greater than/less than [ In reply to ]
Yes. Check out how Date support is implemented. As a quick
workaround... you could piggy-back on Lucene's existing date support
by creating a Date via milliseconds that is the number your are
trying to put in the index.

Note that internally, a bit-vector is created that is the same size
as the index which might cause performance problems depending on the
size of your index and typical queries you will have in your
environment.

~ Dave Smiley

On Tuesday, May 21, 2002, at 08:53 PM, Victor Hadianto wrote:

> Can I use lucene to search greater than / less than a value in the
> field? I
> have a field in the document that function as a score. I would need
> to be
> able to search the index + the option having to say a field > 50
>
> Regards,
>
> --
> Victor Hadianto
>
> --
> To unsubscribe, e-mail: <mailto:lucene-user-
> unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:lucene-user-
> help@jakarta.apache.org>
>


--
To unsubscribe, e-mail: <mailto:lucene-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:lucene-user-help@jakarta.apache.org>
Re: Searching greater than/less than [ In reply to ]
Hello,

I believe that is not possible with Lucene.
Although there is something called a RangeQuery, which may be helpful.

http://jakarta.apache.org/lucene/docs/api/org/apache/lucene/search/RangeQuery.html

Otis

--- Victor Hadianto <victorh@nuix.com.au> wrote:
> Can I use lucene to search greater than / less than a value in the
> field? I
> have a field in the document that function as a score. I would need
> to be
> able to search the index + the option having to say a field > 50
>
> Regards,
>
> --
> Victor Hadianto
>
> --
> To unsubscribe, e-mail:
> <mailto:lucene-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail:
> <mailto:lucene-user-help@jakarta.apache.org>
>


__________________________________________________
Do You Yahoo!?
LAUNCH - Your Yahoo! Music Experience
http://launch.yahoo.com

--
To unsubscribe, e-mail: <mailto:lucene-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:lucene-user-help@jakarta.apache.org>
RE: Searching greater than/less than [ In reply to ]
As long at the field can be sorted alphabetically, you can build your own
filter.

If you put your field in as the same length number, i.e.

001
010
136

Then you can build a filter (that will be mostly cut and paste from the date
filter class)

which will allow you to do less than and greater than operations.

Dan





-----Original Message-----
From: Victor Hadianto [mailto:victorh@nuix.com.au]
Sent: Tuesday, May 21, 2002 7:54 PM
To: lucene-user@jakarta.apache.org
Subject: Searching greater than/less than


Can I use lucene to search greater than / less than a value in the field? I
have a field in the document that function as a score. I would need to be
able to search the index + the option having to say a field > 50

Regards,

--
Victor Hadianto

--
To unsubscribe, e-mail:
<mailto:lucene-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail:
<mailto:lucene-user-help@jakarta.apache.org>

--
To unsubscribe, e-mail: <mailto:lucene-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:lucene-user-help@jakarta.apache.org>
RE: Searching greater than/less than [ In reply to ]
Just a note - I have used this method (the date filtering style of
filtering) on an index of 12 million documents, and haven't had a problem
with performance.

I need to set up some tests, however, and see if it is faster to filter with
the date filter style of filtering, or filter by building the query for
every number you want returned.

My guess is that if you are looking for numbers on the scale of 10 < x < 50
it would be faster to write the query to search for 11, 12, 13, 14, 15, ....
49

But if you are looking for numbers on the scale of 5 < x < 10000 it will be
faster to do the date filter style of filtering.

This is just a hunch, however, and I'm sure depends on the range of numbers
in your index, and the number of docs in it. It would be nice to know,
however, roughly where the scale tips from one way being faster than the
other.

If anyone has tested this, maybe an entry on the FAQ page is in order.

Or, the whole thing could be alleviated, if lucene supported a number field,
rather than just text, and date field (which seems like it was implemented
as an afterthought, and is useless (as written) if your dates go farther
back than ~1970.

Maybe put that on the list of possible next version ideas.



-----Original Message-----
From: David Smiley [mailto:dsmiley@mac.com]
Sent: Tuesday, May 21, 2002 8:54 PM
To: Lucene Users List
Subject: Re: Searching greater than/less than


Yes. Check out how Date support is implemented. As a quick
workaround... you could piggy-back on Lucene's existing date support
by creating a Date via milliseconds that is the number your are
trying to put in the index.

Note that internally, a bit-vector is created that is the same size
as the index which might cause performance problems depending on the
size of your index and typical queries you will have in your
environment.

~ Dave Smiley

On Tuesday, May 21, 2002, at 08:53 PM, Victor Hadianto wrote:

> Can I use lucene to search greater than / less than a value in the
> field? I
> have a field in the document that function as a score. I would need
> to be
> able to search the index + the option having to say a field > 50
>
> Regards,
>
> --
> Victor Hadianto
>
> --
> To unsubscribe, e-mail: <mailto:lucene-user-
> unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:lucene-user-
> help@jakarta.apache.org>
>


--
To unsubscribe, e-mail:
<mailto:lucene-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail:
<mailto:lucene-user-help@jakarta.apache.org>

--
To unsubscribe, e-mail: <mailto:lucene-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:lucene-user-help@jakarta.apache.org>