Class Ferret::Index::LazyDoc
In: ext/r_index.c
Parent: Hash

Summary

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.

Example

  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]

Methods

default   fields   load  

Classes and Modules

Class Ferret::Index::LazyDoc::LazyDocData

Public Instance methods

This method is used internally to lazily load fields. You should never really need to call it yourself.

Returns the list of fields stored for this particular document. If you try to access any of these fields in the document the field will be loaded. Try to access any other field an nil will be returned.

Load all unloaded fields in the document from the index.

[Validate]