Chapter 9. Searching
This chapter covers
- The Zend_Search_Lucene component
- How to add a search page to a real-world application
- The Observer pattern and how it helps code separation
One feature that separates an excellent website from a mediocre one is search. It doesn’t matter how good your navigation system is, your users are used to Google and expect that they can search your website to find what they’re looking for. If they can’t search, or if the search doesn’t return useful results, they’ll try another site and another until they find one that does. A good search system is hard to write, but Zend Framework provides the Zend_Search_Lucene component to make it easier.
In this chapter, we’ll look at how search should work for the user and at how the Zend_Search_Lucene component works. We’ll then integrate search into our Places website, looking at how to index a model and how to present results to the user.
For most of us, we get the best from a website when we successfully read the information we came for. For an e-commerce site, this generally means finding the item and purchasing it. For other sites, we’re generally looking for relevant articles on the topics that interest us. Searching is one way to help a user to quickly find the results they’re looking for. A good search system will provide the most relevant results at the top.