I just tried to convert my code to 0.10 … But i’m currently not sure
how to use fields…
i really like some of the new api… its leaner and i like the fact that
these strange consts are gone (like
Ferret::Search::BooleanClause::Occur::MUST) …
I see that you’re now having Ferret::Index::FieldInfo to describe the
fields of the index… thats good… and i now see that documents and
fields are much smaller and easier to create… thats good as well
now what i dont get is how to add a field to a document… i can create a
new field or a document, but how to make give the field a name? i would
expect something like
doc = Document.new
fiels = Field.new(“my data to be indexed”, 1.5)
doc.add_field( ‘title’, field )
NOTE: all fields should now be Symbols. Strings will work in most
cases but Symbols are what is expected. They’re much more efficient
anyway.
what if i add a field to a doc that was not initialized using
fieldinfos?
will this be added anyway and just fallback to the default fieldinfos?
is there a way to prevent fields from beeing added if there is no
fieldinfo definition? And if not, will there be a way?
what if i add a field to a doc that was not initialized using fieldinfos?
will this be added anyway and just fallback to the default fieldinfos?
is there a way to prevent fields from beeing added if there is no
fieldinfo definition? And if not, will there be a way?
Thanks,
Ben
Great question. Another thing I should elloborate on. When you create
the FieldInfos object you can set the default fields for any unknown
fields you add later. For example
fi = FieldInfos.new(:store => :no, :term_vector => :no)
# fields are normally stored by default but now we've set the
default :store
# value to :no so we need to explicitly state that we want to store
fields;
fi.add_fields(:title, :store => :yes, :index => :untokenized)
index = Index.new(:field_infos => fi)
index << {:title => "asdg", :content => "asdlkgjhasdkgjh"}
Cheers,
Dave
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.