Thanks for the reply. I expected the results to be sorted in reverse chron (i.e. more recent time stamps first) because my Sort object is:
new Sort (DATE_FIELD, true); Using my previous example, I would expect to see the following (because 48 seconds is more recent than 24 seconds): September 05, 2007, 14:02:51 (20070905140251) September 02, 2007, 23:30:48 (20070902233048) September 02, 2007, 23:30:24 (20070902233024) ... ... It looks to me like the Date part is sorted correctly but not the Time part. Am I missing something? > Date: Thu, 18 Oct 2007 20:46:36 -0400 > From: [EMAIL PROTECTED] > To: java-user@lucene.apache.org > Subject: Re: Sort by date with Lucene 2.2.0 ... > > Maybe I'm missing something, but that looks like the correct > order to me, they are both on September 02, 2007, 11:30 P.M, and > ]24 seconds is before 48 seconds..... > > Or is it just late and I'm missing the obvious (a specialty of mine)... > > Erick > > On 10/18/07, Dragon Fly <[EMAIL PROTECTED]> wrote: > > > > > > Hi, > > > > I'm am trying to sort a date field in my index but I'm seeing strange > > results. I have searched the Lucene user mail archive for Datetools but > > still couldn't figure out the problem. > > > > The date field is indexed as follows (i.e. DateTools is used, date field > > is stored and untokenized): > > > > String dateString = DateTools.dateToString (myDateObject, > > DateTools.Resolution.SECOND); > > Field field = new Field (DATE_FIELD, dateString, Field.Store.YES, > > Field.Index.UN_TOKENIZED); > > field.setOmitNorms (true); > > document.add (field); > > > > ===== > > > > I executed the search with a reverse sort on the DATE_FIELD: > > > > QueryParser queryParser = new QueryParser ("field1", new StandardAnalyzer > > ()); > > Query query = queryParser.parse ("txt:\"sum\""); > > IndexSearcher searcher = new IndexSearcher (indexDirectory); > > TopFieldDocs topFieldDocs = searcher.search (query, null, 10000, new Sort > > (DATE_FIELD, true)); > > > > for (int i = 0; i < topFieldDocs.totalHits; i++) > > { > > Document document = searcher.doc (topFieldDocs.scoreDocs[i].doc); > > String date = document.get (DATE_FIELD); > > > > System.out.println (date); > > } > > > > ==== > > > > As you can see, the output below is not sorted correctly (e.g. > > 20070902233024 comes before 20070902233048). Does anyone know what the > > problem is? Thank you. > > > > > > 20070905140251 > > 20070902233024 > > 20070902233048 > > 20070902234113 > > 20070901040321 > > 20070901040751 > > 20070901040922 > > 20070901042706 > > 20070901042603 > > 20070901050936 > > 20070901050935 > > 20070901050935 > > 20070901080218 > > > > > > _________________________________________________________________ > > Windows Live Hotmail and Microsoft Office Outlook – together at last. Get > > it now. > > > > http://office.microsoft.com/en-us/outlook/HA102225181033.aspx?pid=CL100626971033 _________________________________________________________________ Peek-a-boo FREE Tricks & Treats for You! http://www.reallivemoms.com?ocid=TXT_TAGHM&loc=us