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 Filip Anselm <fi...@nable.dk> on 2005/09/03 22:15:54 UTC
How to search between dates?
Hi
If I add a Field with a date to all my indexed documents... how can I
then search and only get the hits where the date Field is between two
specified dates??
Thank you in advance!
Filip
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org
RE: How to search between dates?
Posted by houyang <hu...@oracle.com>.
"YYYYMMDD" is better since it has less number unique terms compared with the unix time stamp if you only care about the days.
-----Original Message-----
From: Filip Anselm [mailto:filip@nable.dk]
Sent: Sunday, September 04, 2005 3:56 AM
To: java-user@lucene.apache.org
Subject: Re: How to search between dates?
DateFilter sounds great!! - But how is the best way to store dates in af
Field? I get the time as a unix time stamp, seconds since epoch - and
usually I can cut it down to hours or days since ephoc instead - if this
has any effect on the perfomance...
thanks...
Chris Hostetter wrote:
>: How do I combine two queries - one made by the QueryParser and the
>: programmatically made RangeQuery?
>
>you could make them both children of a single BooleanQuery, but as long as
>you're going to write a little java code to put them together -- why not
>use a DateFilter instead?
>
>http://lucene.apache.org/java/docs/api/org/apache/lucene/search/DateFilter.html
>
>...it's more efficient then a RangeQuery, it doesn't have the same
>"TooManyCLauses" limitations as a RangeQuery, and it would artificially
>affect the score of your results.
>
>
>
>
>-Hoss
>
>
>---------------------------------------------------------------------
>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
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org
Re: How to search between dates?
Posted by Filip Anselm <fi...@nable.dk>.
DateFilter sounds great!! - But how is the best way to store dates in af
Field? I get the time as a unix time stamp, seconds since epoch - and
usually I can cut it down to hours or days since ephoc instead - if this
has any effect on the perfomance...
thanks...
Chris Hostetter wrote:
>: How do I combine two queries - one made by the QueryParser and the
>: programmatically made RangeQuery?
>
>you could make them both children of a single BooleanQuery, but as long as
>you're going to write a little java code to put them together -- why not
>use a DateFilter instead?
>
>http://lucene.apache.org/java/docs/api/org/apache/lucene/search/DateFilter.html
>
>...it's more efficient then a RangeQuery, it doesn't have the same
>"TooManyCLauses" limitations as a RangeQuery, and it would artificially
>affect the score of your results.
>
>
>
>
>-Hoss
>
>
>---------------------------------------------------------------------
>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
Re: How to search between dates?
Posted by Chris Hostetter <ho...@fucit.org>.
: How do I combine two queries - one made by the QueryParser and the
: programmatically made RangeQuery?
you could make them both children of a single BooleanQuery, but as long as
you're going to write a little java code to put them together -- why not
use a DateFilter instead?
http://lucene.apache.org/java/docs/api/org/apache/lucene/search/DateFilter.html
...it's more efficient then a RangeQuery, it doesn't have the same
"TooManyCLauses" limitations as a RangeQuery, and it would artificially
affect the score of your results.
-Hoss
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org
Re: How to search between dates?
Posted by Filip Anselm <fi...@nable.dk>.
jian => I'll try the RangeQuery first, and if it doesn't give any
perfomance problems I'll just stick to that method - it's easy, simple
and doens't involve other systems. But thanks for info...
How do I combine two queries - one made by the QueryParser and the
programmatically made RangeQuery?
Filip
jian chen wrote:
>Hi,
>
>The other way maybe, store the date in a separate database, like derby
>embeded database. Then, do a joint query between the Lucene result and the
>derby database select result, and merge the two result set into one by
>handing coding a database intersection like type of operation.
>
>Just a thought but I am looking into using derby to store all the
>numeric/date data that requires range query, and only store in Lucene the
>free text data. Then, using a primary key to associate the two.
>
>Since typically, range query is best handled by B+ tree indexing, so, that
>is why I want to give derby a try and see how to best integrate it with
>Lucene.
>
>Cheers,
>
>Jian
>
>On 9/3/05, Otis Gospodnetic <ot...@yahoo.com> wrote:
>
>
>>You can use the date range query. See:
>>http://lucene.apache.org/java/docs/queryparsersyntax.html
>>http://www.lucenebook.com/search?query=range+query
>>
>>Otis
>>
>>--- Filip Anselm <fi...@nable.dk> wrote:
>>
>>
>>
>>>Hi
>>>
>>>If I add a Field with a date to all my indexed documents... how can I
>>>then search and only get the hits where the date Field is between two
>>>specified dates??
>>>
>>>Thank you in advance!
>>>
>>>Filip
>>>
>>>
>>>---------------------------------------------------------------------
>>>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
>>
>>
>>
>>
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org
Re: How to search between dates?
Posted by jian chen <ch...@gmail.com>.
Hi,
The other way maybe, store the date in a separate database, like derby
embeded database. Then, do a joint query between the Lucene result and the
derby database select result, and merge the two result set into one by
handing coding a database intersection like type of operation.
Just a thought but I am looking into using derby to store all the
numeric/date data that requires range query, and only store in Lucene the
free text data. Then, using a primary key to associate the two.
Since typically, range query is best handled by B+ tree indexing, so, that
is why I want to give derby a try and see how to best integrate it with
Lucene.
Cheers,
Jian
On 9/3/05, Otis Gospodnetic <ot...@yahoo.com> wrote:
>
> You can use the date range query. See:
> http://lucene.apache.org/java/docs/queryparsersyntax.html
> http://www.lucenebook.com/search?query=range+query
>
> Otis
>
> --- Filip Anselm <fi...@nable.dk> wrote:
>
> > Hi
> >
> > If I add a Field with a date to all my indexed documents... how can I
> > then search and only get the hits where the date Field is between two
> > specified dates??
> >
> > Thank you in advance!
> >
> > Filip
> >
> >
> > ---------------------------------------------------------------------
> > 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
>
>
Re: How to search between dates?
Posted by Otis Gospodnetic <ot...@yahoo.com>.
You can use the date range query. See:
http://lucene.apache.org/java/docs/queryparsersyntax.html
http://www.lucenebook.com/search?query=range+query
Otis
--- Filip Anselm <fi...@nable.dk> wrote:
> Hi
>
> If I add a Field with a date to all my indexed documents... how can I
> then search and only get the hits where the date Field is between two
> specified dates??
>
> Thank you in advance!
>
> Filip
>
>
> ---------------------------------------------------------------------
> 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