Hi,

I just noticed that Ferret seems to convert every field to a string
[ruby code appended for those interested], which has thwarted my attempt
to format Dates (to "dd/mm/yyyy") and Floats (to "n.nn") for consumption
further down the line based on the class of the field stored.

I considered pre-formatting Dates and Floats prior to indexing, which
would store the field exactly as I need for presentation purposes,
however I would lose sorting and range searching.

I'm wondering what approaches people are using to manage formatting post
retrieve from Ferret. 

Any pointers appreciated,

Kind Regards

Neville
==========================

require 'rubygems'
require 'ferret'
require 'date'

p Ferret::VERSION

@dir = Ferret::Store::RAMDirectory.new
@index = Ferret::Index::Index.new(:dir => @dir)

invoice = {:invoice_date => Date.new(2006,9,20), :invoice_value =>
44.50, :invoice_no => 45656, :invoice_to => 'Nev'}

@index << invoice

doc = @index[0].load

doc.fields.each do |f|
  p f
  p doc[f].class
  p doc[f]
end

==========================

>ruby test_format.rb
"0.10.6"
:invoice_date
String
"2006-09-20"
:invoice_value
String
"44.5"
:invoice_no
String
"45656"
:invoice_to
String
"Nev"
_______________________________________________
Ferret-talk mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/ferret-talk

Reply via email to