ZSearch operates with documents as atomic subjects for indexing. A document is divided into named fields, and fields have content that can be searched.
A documented is represented by the Zend_Search_Lucene_Document object, and this object contains Zend_Search_Lucene_Field objects that represent the fields.
Zend_Search_Lucene_Field
class provides several static methods to create fields with
different characteristics:
$doc = new Zend_Search_Lucene_Document(); // Field is not tokenized, but is indexed and stored within the index. // Stored fields can be retrived from the index. $doc->addField(Zend_Search_Lucene_Field::Keyword('doctype', 'autogenerated')); // Field is not tokenized nor indexed, but is stored in the index. $doc->addField(Zend_Search_Lucene_Field::UnIndexed('created', time())); // Binary String valued Field that is not tokenized nor indexed, // but is stored in the index. $doc->addField(Zend_Search_Lucene_Field::Binary('icon', $iconData)); // Field is tokenized and indexed, and is stored in the index. $doc->addField(Zend_Search_Lucene_Field::Text('annotation', 'Document annotation text...')); // Field is tokenized and indexed, but that is not stored in the index. $doc->addField(Zend_Search_Lucene_Field::UnStored('contents', 'My cool document content..'));
You could give names for fields by your own choice. 'contents' field name is used to search by default. Thus that's good idea to place main document data into the field with this name.