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 abdul aleem <ja...@yahoo.com> on 2006/12/18 17:09:31 UTC

Range Filter again - (time field)

Hello All,

Iam pretty sure there has been lots of discussions
and threads on date issues however coudln't nail
down my syntax,  bear with me if this has been asked
before

I have split my timestamp as Date and Time and 
indexing on both 

Im getting time as

SimpleDateFormat sdf = new
SimpleDateFormat("hh:mm:ss.SSS");

Date date = sdf.parse(time);

Timestamp timestamp = new Timestamp(date.getTime());

String dateString = DateTools.dateToString(timestamp, 

DateTools.Resolution.MILLISECOND);
Field timeField = new
Field("time",dateString,Field.Store.YES,
Field.Index.UN_TOKENIZED);

For searching ( can search indexed time?? )
============================================
RangeFilter df2 = new RangeFilter("time",
DateTools.dateToString(startTime,
DateTools.Resolution.MILLISECOND),
                 DateTools.dateToString(endTime,
DateTools.Resolution.MILLISECOND), true, true);


Result
=======
*time* index has more than 50 documents in start and
end range  but RangeFilter returns only 1 document (if
inclusive only)


is there something wrong with way iam using
RangeFilter ?? 

I would greatly appreciate if someone could suggest on
the above.


Many thanks,
Abdul 

PS:- Im searching on the exact time that was used to
index in the RangeFilter












__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

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


Re: Range Filter again - (time field)

Posted by Pa...@saaconsultants.com.

Hello Abdul,

The approach with dates and times is to index the full date and time but to
the resolution that you require as opposed to splitting the time and date
into separate fields.

 If you have a requirement to search to millisecond resolution then index
to millisecond resolutiuon using DateTools.Resolution.MILLISECOND. If you
only need your search to be accurate to the day then index using
DateTools.Resolution.DAY. If you need both then either index both and
choose the appropriate one at search time or store to millisecond
resolution and accpet the performance penalty.

Looking at you code it seems that you're just storing the time information
in the index and have lost the date information. This may account for the
range filter not picking up what you would expect as the dates may be
different. This is only a guess though.

Another observation is that you shouldn't have to use the Timestamp class.
If I remember this is an extension to the standard Date class that gives
nanosecond resolution. You should just be able to create the dataString
using

dataString = DateTools.dateToString(date,
DateTools.Resolution.MILLISECOND);

Hope this is of some help

Regards
Paul I.




                                                                           
             abdul aleem                                                   
             <janaabdulaleem@y                                             
             ahoo.com>                                                  To 
                                       java-user@lucene.apache.org         
             18/12/2006 16:10                                           cc 
                                                                           
                                                                   Subject 
             Please respond to         Range Filter again - (time field)   
             java-user@lucene.                                             
                apache.org                                                 
                                                                           
                                                                           
                                                                           
                                                                           




Hello All,

Iam pretty sure there has been lots of discussions
and threads on date issues however coudln't nail
down my syntax,  bear with me if this has been asked
before

I have split my timestamp as Date and Time and
indexing on both

Im getting time as

SimpleDateFormat sdf = new
SimpleDateFormat("hh:mm:ss.SSS");

Date date = sdf.parse(time);

Timestamp timestamp = new Timestamp(date.getTime());

String dateString = DateTools.dateToString(timestamp,

DateTools.Resolution.MILLISECOND);
Field timeField = new
Field("time",dateString,Field.Store.YES,
Field.Index.UN_TOKENIZED);

For searching ( can search indexed time?? )
============================================
RangeFilter df2 = new RangeFilter("time",
DateTools.dateToString(startTime,
DateTools.Resolution.MILLISECOND),
                 DateTools.dateToString(endTime,
DateTools.Resolution.MILLISECOND), true, true);


Result
=======
*time* index has more than 50 documents in start and
end range  but RangeFilter returns only 1 document (if
inclusive only)


is there something wrong with way iam using
RangeFilter ??

I would greatly appreciate if someone could suggest on
the above.


Many thanks,
Abdul

PS:- Im searching on the exact time that was used to
index in the RangeFilter












__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

---------------------------------------------------------------------
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