Hibernate Books

All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Case Insensitive sorting
PostPosted: Wed Nov 23, 2011 7:06 am 
Regular
Regular

Joined: Tue May 17, 2011 1:45 am
Posts: 52
Hi ,

By default Lucene seems to do a case sensitive sort on a field. However I tried storing the field with an analyzer as LowerCaseFactory but it dint work.

Is there a way to make sorting case insensitive?

Thanks


Top
 Profile  
 
 Post subject: Re: Case Insensitive sorting
PostPosted: Thu Nov 24, 2011 7:11 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
Lower-casing the field to sort on should work. Of course the value should still be single valued, meaning it should not be tokenized. Maybe it would help if you share some code!?

--Hardy


Top
 Profile  
 
 Post subject: Re: Case Insensitive sorting
PostPosted: Thu Nov 24, 2011 5:19 pm 
Regular
Regular

Joined: Tue May 17, 2011 1:45 am
Posts: 52
Here is the sample code I was trying to do but dint work

@AnalyzerDef(name = "sort", tokenizer = @TokenizerDef(factory = StandardTokenizerFactory.class), filters = {
@TokenFilterDef(factory = LowerCaseFilterFactory.class)
})
@Field(index = Index.UN_TOKENIZED, store = Store.YES,analyzer = @Analyzer(definition = "sort"))
public String cityName() {
return cityName;
}


Top
 Profile  
 
 Post subject: Re: Case Insensitive sorting
PostPosted: Fri Nov 25, 2011 5:39 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
Hi,

you should not use the StandardTokenizerFactory, since it will tokenize city names with multiple words (eg New York). Use just LowerCaseTokenizerFactory. Not sure if this is your problem. Can you give an example of your sorting issues?

--Hardy


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 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.