-->
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.  [ 4 posts ] 
Author Message
 Post subject: HIbernate search - Searching numbers
PostPosted: Tue Jan 19, 2010 12:18 pm 
Beginner
Beginner

Joined: Wed Dec 16, 2009 10:34 am
Posts: 21
Hello again:

What if i want to search for numbers with a special format like 000000000294. That's because when i query this number there are no results, but when i query for 294.... hibernate search finds it.

What should i do if i want results when i wrote 000000000294??


Top
 Profile  
 
 Post subject: Re: HIbernate search - Searching numbers
PostPosted: Tue Jan 19, 2010 3:58 pm 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
hi, Lucene doesn't have the notion of numbers, just strings and so these have to match exactly.
Probably one of your numbers has been processed to remove leading zeros, make sure you apply the same function to the query.
A QueryParser will apply an Analyzer automatically, if you build the query programmatically you have to run the Analyzer yourself. All what is indexed is analyzed, unless it's explicitly disabled (using UNTOKENIZED)
Using Luke you can inspect your index and "see" how it's being stored in the index.

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


Top
 Profile  
 
 Post subject: Re: HIbernate search - Searching numbers
PostPosted: Tue Jan 19, 2010 5:00 pm 
Beginner
Beginner

Joined: Wed Dec 16, 2009 10:34 am
Posts: 21
Yes !

I used Luke and figured out that the value 000000000294 is indexed as 294.0, that's because of the toString() use by the DoubleBridge.
So, what should i do when the user writes 000000000294 ??, should i write my own bridge ? or just declare that field as untokenized ?

I'll appreciate the help.


Top
 Profile  
 
 Post subject: Re: HIbernate search - Searching numbers
PostPosted: Tue Jan 19, 2010 7:04 pm 
Hibernate Team
Hibernate Team

Joined: Fri Oct 05, 2007 4:47 pm
Posts: 2536
Location: Third rock from the Sun
I would use the same bridge on the user input, so that
00000294=00294=294=294,0=294,00

but it depends on what you need, so it's up to you

_________________
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.  [ 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.