You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by MB Leasing <le...@marketingbrokers.com> on 2007/04/02 21:02:58 UTC
precision double sortable String
Hi,
I'm trying to turn a double with decimal point
precision fifteen digits to the left into a sortable
String for Lucene (.346210426731253).
NumberTools is for longs so doesn't apply.
In Solr, NumberUtils.double2sortableStr prints
out a literal question mark character '?' .
I tried making it a float first but the formatting
also did not work w/NumberUtils.float2sortableStr.
Interestingly, I was able to write a BigDecimal
helper class, use setScale(15), longValue() then
pass it to NumberTools and get a padded result.
.346210426731253 becomes 000000
1.346210426731253 becomes 000001
2.346210426731253 becomes 000002
etc...
Any ideas?
Thanks.
Peter W.
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org
Re: precision double sortable String
Posted by "Peter W." <pe...@marketingbrokers.com>.
One more thing...
It could optionally be indexed and stored as a String
then contents of the Hits object could be placed into
a Collection with a comparator that sorts double
values in reverse order.
Regards,
Peter W.
On Apr 2, 2007, at 12:02 PM, "Peter W." <pe...@marketingbrokers.com>
wrote:
> Hi,
>
> I'm trying to turn a double with decimal point
> precision fifteen digits to the left into a sortable
> String for Lucene (.346210426731253).
>
> NumberTools is for longs so doesn't apply.
>
> In Solr, NumberUtils.double2sortableStr prints
> out a literal question mark character '?' .
>
> I tried making it a float first but the formatting
> also did not work w/NumberUtils.float2sortableStr.
>
> Interestingly, I was able to write a BigDecimal
> helper class, use setScale(15), longValue() then
> pass it to NumberTools and get a padded result.
>
> .346210426731253 becomes 000000
> 1.346210426731253 becomes 000001
> 2.346210426731253 becomes 000002
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org
Re: precision double sortable String
Posted by Yonik Seeley <yo...@apache.org>.
On 4/2/07, MB Leasing <le...@marketingbrokers.com> wrote:
> In Solr, NumberUtils.double2sortableStr prints
> out a literal question mark character '?' .
You shouldn't try to print it out... it's essentially binary :-)
-Yonik
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org