-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 posts ] 
Author Message
 Post subject: [Hibernate Search] Problem when sorting by date
PostPosted: Thu Jun 28, 2007 4:36 am 
Regular
Regular

Joined: Wed Apr 25, 2007 10:29 am
Posts: 110
Location: France
Hello,

I have a field date :
Quote:
@Field(index=Index.TOKENIZED, store=Store.YES)
@DateBridge(resolution=Resolution.SECOND)
private Date date;


For exemple, if I insert 2 values, in my lucene Indexes, I have :
Image
and
Image

When I made a sort by "titre", there is no problem.

When I made a sort by date or reverse date :
fullTextQuery.setSort(new Sort("date",false));
fullTextQuery.setSort(new Sort("date",true));
the result is the same !

Thank you


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 29, 2007 11:07 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
At least the field should not be tokenized

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 29, 2007 11:18 am 
Regular
Regular

Joined: Wed Apr 25, 2007 10:29 am
Posts: 110
Location: France
Yes, now, it is UN_TOKENIZED, but there is the same problem. I will see later ... hollydays ;)

Thank you for all Emmanuel.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 10, 2007 4:14 am 
Regular
Regular

Joined: Wed Apr 25, 2007 10:29 am
Posts: 110
Location: France
Back from hollydays ...

My Entite class :
Code:
@Indexed
public class Entite
{
   @DocumentId
   private Integer id;

   @Field(index=Index.TOKENIZED, store=Store.YES)
   private String titre;

   @Field(index=Index.UN_TOKENIZED, store=Store.YES)
   @Transient
   @SuppressWarnings("unused")
   private String titreSort;

   @Field(index=Index.TOKENIZED, store=Store.YES)
   private String resume;

   @Field(index=Index.UN_TOKENIZED, store=Store.YES)
   @DateBridge(resolution=Resolution.SECOND)
   private Date date;

   ...
}


I inserted 2 objects and these are my indexes :
Image
and
Image

The result of
Code:
fullTextQuery.setSort(new Sort("date", false));

and
Code:
fullTextQuery.setSort(new Sort("date", true));

is the same :S


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 11, 2007 2:12 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Well it works fine in the unit test suite.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 17, 2007 4:56 am 
Regular
Regular

Joined: Wed Apr 25, 2007 10:29 am
Posts: 110
Location: France
I made a test here :
http://opensource.atlassian.com/project ... HSEARCH-97


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 24, 2007 7:30 am 
Regular
Regular

Joined: Wed Apr 25, 2007 10:29 am
Posts: 110
Location: France
It's a Lucene bug, thank you Emmanuel ;).

The solution is :
fullTextQuery.setSort(new Sort(new SortField( "date", SortField.STRING, true )));


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.