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 Weiwei Wang <ww...@gmail.com> on 2009/12/09 04:23:02 UTC

HOW to do date range searchi in 3.0

Hi, all
     I need to do a date range search like date:[a previous time to null]
I used a filter to do this job, the code  is shown below:
    Calendar c = Calendar.getInstance();
    c.setTimeInMillis(c.getTimeInMillis() -
parameter.getRecentUpdateConstraint()
        * RosaCrawlerConstants.ONE_DAY_IN_MILLISECOND);
    String fromTime = DateTools.dateToString(c.getTime(),
DateTools.Resolution.DAY);
    Query updateTimeRange = new
TermRangeQuery("updateTime",fromTime,null,true,false);
    query.add(updateTimeRange, BooleanClause.Occur.MUST);

However, it doesn't work as before in version 2.4.1(I'm updating my project
from version 2.4.1 to lucenen 3.0.0)

Could anybody here offer me a solution?
-- 
Weiwei Wang
Alex Wang
王巍巍
Room 403, Mengmin Wei Building
Computer Science Department
Gulou Campus of Nanjing University
Nanjing, P.R.China, 210093

Homepage: http://cs.nju.edu.cn/rl/weiweiwang

Re: HOW to do date range searchi in 3.0

Posted by Weiwei Wang <ww...@gmail.com>.
Thanks, Uwe. I've found the problem. the updateTime field is lost when i
converted my index from an older version.

Another question, is there any detailed tutorial about Lucene 3.0.0?

2009/12/9 Uwe Schindler <uw...@thetaphi.de>

> How did you index your date?
>
> I would suggest to reindex the date using NumericField! And then query
> using
> NumericRangeQuery. If reindexing is not possible the Query like you have
> done, should work. Please give us examples of how you indexed and how you
> query.
>
> Uwe
>
> -----
> Uwe Schindler
> H.-H.-Meier-Allee 63, D-28213 Bremen
> http://www.thetaphi.de
> eMail: uwe@thetaphi.de
>
> > -----Original Message-----
> > From: Weiwei Wang [mailto:ww.wang.cs@gmail.com]
> > Sent: Wednesday, December 09, 2009 4:23 AM
> > To: java-user@lucene.apache.org
> > Subject: HOW to do date range searchi in 3.0
> >
> > Hi, all
> >      I need to do a date range search like date:[a previous time to null]
> > I used a filter to do this job, the code  is shown below:
> >     Calendar c = Calendar.getInstance();
> >     c.setTimeInMillis(c.getTimeInMillis() -
> > parameter.getRecentUpdateConstraint()
> >         * RosaCrawlerConstants.ONE_DAY_IN_MILLISECOND);
> >     String fromTime = DateTools.dateToString(c.getTime(),
> > DateTools.Resolution.DAY);
> >     Query updateTimeRange = new
> > TermRangeQuery("updateTime",fromTime,null,true,false);
> >     query.add(updateTimeRange, BooleanClause.Occur.MUST);
> >
> > However, it doesn't work as before in version 2.4.1(I'm updating my
> > project
> > from version 2.4.1 to lucenen 3.0.0)
> >
> > Could anybody here offer me a solution?
> > --
> > Weiwei Wang
> > Alex Wang
> > 王巍巍
> > Room 403, Mengmin Wei Building
> > Computer Science Department
> > Gulou Campus of Nanjing University
> > Nanjing, P.R.China, 210093
> >
> > Homepage: http://cs.nju.edu.cn/rl/weiweiwang
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>


-- 
Weiwei Wang
Alex Wang
王巍巍
Room 403, Mengmin Wei Building
Computer Science Department
Gulou Campus of Nanjing University
Nanjing, P.R.China, 210093

Homepage: http://cs.nju.edu.cn/rl/weiweiwang

RE: HOW to do date range searchi in 3.0

Posted by Uwe Schindler <uw...@thetaphi.de>.
How did you index your date?

I would suggest to reindex the date using NumericField! And then query using
NumericRangeQuery. If reindexing is not possible the Query like you have
done, should work. Please give us examples of how you indexed and how you
query.

Uwe

-----
Uwe Schindler
H.-H.-Meier-Allee 63, D-28213 Bremen
http://www.thetaphi.de
eMail: uwe@thetaphi.de

> -----Original Message-----
> From: Weiwei Wang [mailto:ww.wang.cs@gmail.com]
> Sent: Wednesday, December 09, 2009 4:23 AM
> To: java-user@lucene.apache.org
> Subject: HOW to do date range searchi in 3.0
> 
> Hi, all
>      I need to do a date range search like date:[a previous time to null]
> I used a filter to do this job, the code  is shown below:
>     Calendar c = Calendar.getInstance();
>     c.setTimeInMillis(c.getTimeInMillis() -
> parameter.getRecentUpdateConstraint()
>         * RosaCrawlerConstants.ONE_DAY_IN_MILLISECOND);
>     String fromTime = DateTools.dateToString(c.getTime(),
> DateTools.Resolution.DAY);
>     Query updateTimeRange = new
> TermRangeQuery("updateTime",fromTime,null,true,false);
>     query.add(updateTimeRange, BooleanClause.Occur.MUST);
> 
> However, it doesn't work as before in version 2.4.1(I'm updating my
> project
> from version 2.4.1 to lucenen 3.0.0)
> 
> Could anybody here offer me a solution?
> --
> Weiwei Wang
> Alex Wang
> 王巍巍
> Room 403, Mengmin Wei Building
> Computer Science Department
> Gulou Campus of Nanjing University
> Nanjing, P.R.China, 210093
> 
> Homepage: http://cs.nju.edu.cn/rl/weiweiwang


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