The first part of implementing a solution using it, is
therefore to create an index.
8.2.1 A separate search index for your website
Creating an index for Zend_Search_Lucene is just a case of calling the create() function:
$index = Zend_Search_Lucene::create('path/to/index');
The index created is actually a directory that contains a few files in a format that is compatible with the
main Apache Lucene project. This means that if you want to, you could create index files using the Java or
.Net applications, or conversely, create indexes with Zend_Search_Lucene and search them using Java.
Having created the index, the next thing to do is to put data in it for searching on. This is where it gets
complicated and we have to pay attention! Adding data is easily done using the addDocument() method,
however you need to set up the fields within the document and each field has a type.
For example:
$doc = new Zend_Search_Lucene_Document();
$doc->addField(Zend_Search_Lucene_Field::UnIndexed('url', $url));
$doc->addField(Zend_Search_Lucene_Field::UnStored('contents', $contents));
$doc->addField(Zend_Search_Lucene_Field::Text('desc', $desc));
$index->addDocument($doc);
As you can see in this example, the url data is of field type ???UnIndexed???, contents are ???UnStored??? and the
description is ???Text???.
Pages:
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214