This is done using the
optional third parameter of the field creation methods, for example:
$doc = new Zend_Search_Lucene_Document();
$doc->addField(Zend_Search_Lucene_Field::Text('body', $body, 'iso-8859-1'));
Let??™s do something interesting with Zend_Search_Lucene and integrate searching into the Places website.
8.3 Adding search to Places
As Places is a community site, a search facility will be expected by its members. We will implement a simple
???one field??? search available on every page in the side bar so that it is very easy for users to find what they
want. The results will look like Figure 8.2.
Figure 8.2 Search results page for Places. Each entry has a title which is linked to the page followed by a summary. The results are
ranked by the search engine so that the most relevant are at the top.
In order to achieve this, we are going to create the index files used by the search first and then we will
write the simple form and search results page, finishing with the advanced search form.
8.3.1 Updating the index as new content is added
We have two choices when to create index files: when adding data to the database or as a scheduled task using
cron or similar. A lot depends on the traffic that the site receives as to when the additional stress of creating an
index is done.
Pages:
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225