If your date field is not in the form something like 'YYYYMMDD HHmmss' your sort will be wrong(since it is a string comparison).
DIGY -----Original Message----- From: Granroth, Neal V. [mailto:[EMAIL PROTECTED] Sent: Wednesday, August 13, 2008 10:07 PM To: lucene-net-user@incubator.apache.org Subject: RE: problem in the sorting the results from lucene. In your search app, the BooleanQuery object is unnecessary as you have only added one query to it. Try this instead: Hits *hits = searcher->Search(query,sort); I am not very confident that this is the problem, but there is a possiblity that the BooleanQuery, as you constructed, it is confusing sort. If that does not cure the problem then I would look at the index construction code. The content of the "EDITDATE" field must be a string, integer, or float (according to "Lucene in Action" for Lucene version 1.9.1). I notice that you are flagging the field as "Store::NO", it is possible that this needs to be "Store::Yes". In my application, all of the fields for which I have successfully used sort are added to the document using C# statements similar to this: doc.Add( Field.Keyword("filetype", sType ) ); Hope this provides some clues to a solution. -- Neal -----Original Message----- From: Ravi [mailto:[EMAIL PROTECTED] Sent: Wednesday, August 13, 2008 8:45 AM To: lucene-net-user@incubator.apache.org Subject: problem in the sorting the results from lucene. Hi, i am facing some problems in sorting the results from lucene. I want to sort the result according to the date of an object. I have used "EDITDATE" field for this purpose as shown below: doc->Add(new Field("EDITDATE",ix->getEditDate(s)->ToString(),Lucene::Net::Documents::Fiel d::Store::NO,Lucene::Net::Documents::Field::Index::UN_TOKENIZED)); I have read in the 'Lucene in Action' that, the field which we are going to use for sorting must be indexed but UN_TOKENIZED. But i get the results in random order... I am using following code in the search app: Query *query = qp->Parse(querydata->ToString()); BooleanQuery *boolquery = new BooleanQuery(); boolquery->Add(query,BooleanClause::Occur::MUST); Sort *sort = new Sort("EDITDATE",true); Hits *hits = searcher->Search(boolquery,sort); So can you please suggest, what is wrong in this example? -- Thanks & Regards... Ravindra V. Gaikwad. S.E., Colayer Gmbh.