-->
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.  [ 3 posts ] 
Author Message
 Post subject: Lucene integer Range search
PostPosted: Wed May 21, 2008 5:20 am 
Beginner
Beginner

Joined: Thu Apr 20, 2006 11:51 am
Posts: 44
Hi all
I need to give a range from [80 TO 100] to Lucene
it's not working.. seems to convert these as strings.
how can I solve this prob
thanks


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 21, 2008 11:21 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
Quote:
it's not working.. seems to convert these as strings.


yes, you are right: eveything in the lucene index is a String, and sorting uses "lexicographic sorting".

So Hibernate Search converts numbers and dates to Strings correctly padding a number of "0", you may use org.hibernate.search.bridge.BridgeFactory's public constants as helpers to correctly define the rangequery...

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 21, 2008 11:34 am 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
I'm sorry I was wrong in my previous post, looking at the source I've found it's not true
Hibernate Search automatically pads "0" to numbers.

I should add that even if you indexed all numbers correctly a RangeQuery could be dangerous, especially if you have many possible different values,
look for "Why am I getting a TooManyClauses exception?"
in the Lucene FAQ:
http://wiki.apache.org/lucene-java/LuceneFAQ

If you are aware of the dangers of a RangeQuery but still want to use it you should implement your own StringBridge, and use org.apache.lucene.document.NumberTools.

_________________
Sanne
http://in.relation.to/


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.