Class | Ferret::Index::LazyDoc::LazyDocData |
In: |
ext/r_index.c
|
Parent: | Object |
Document-class: Ferret::Index::LazyDoc
When a document is retrieved from the index a LazyDoc is returned. Actually, LazyDoc is just a modified Hash object which lazily adds fields to itself when they are accessed. You should not that they keys method will return nothing until you actually access one of the fields. To see what fields are available use LazyDoc#fields rather than LazyDoc#keys. To load all fields use the LazyDoc#load method.
doc = index_reader[0] doc.keys #=> [] doc.values #=> [] doc.fields #=> [:title, :content] title = doc[:title] #=> "the title" doc.keys #=> [:title] doc.values #=> ["the title"] doc.fields #=> [:title, :content] doc.load doc.keys #=> [:title, :content] doc.values #=> ["the title", "the content"] doc.fields #=> [:title, :content]