On 8/24/06, Jens Kraemer <[EMAIL PROTECTED]> wrote:
> On Wed, Aug 23, 2006 at 08:22:42PM +0200, Benjamin Krause wrote:
> > Hey ...
> >
> > 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 )
> >
> > or
> >
> > doc.title = field ..
> >
> > can't see anything like that in the API though..
>
> it's as easy as doc[:title] = field
>
> Jens

Just to clarify. Hashes are the new Documents. If you don't use the
boost field then use a Hash. It's much simpler. Everyone knows how to
use a Hash.

    index << {:title => "Shawshank Redemption", :tags => ["Drama",
"Suspense", "Jail", "Prison"]}

In fact if you don't want to use the Document class at all;

    class Hash
        include BoostMixin
    end

    doc = {:title => "Shawshank Redemption", :tags => ["Drama",
"Suspense", "Jail", "Prison"]}

    doc.boost = 100.0

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.

I mean to do a big write up explaining the changes but I just don't
have the time right now. Perhaps tomorrow.

Cheers,
Dave
_______________________________________________
Ferret-talk mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/ferret-talk

Reply via email to