Prev | Current Page 209 | Next

Rob Allen, Nick Lo, and Steven Brown

"Zend Framework in Action"


Example search: category:php
$term = new Zend_Search_Lucene_Index_Term('php', 'category');
$query = new Zend_Search_Lucene_Search_Query_Term($term);
$hits = $index->find($query);
Finds the term ???php??? within the category field. If the second term of the Zend_Search_Lucene_Index_Term constructor
is omitted, then all fields will be searched.
Multi-Term Query Multi-term queries allow for searching through many terms. For each term, you can optionally apply the required or
prohibited modifier. All terms are applied to each document when searching.
Example search: +php power ??“java
$query = new Zend_Search_Lucene_Search_Query_MultiTerm();
$query->addTerm(new Zend_Search_Lucene_Index_Term('php'), true);
$query->addTerm(new Zend_Search_Lucene_Index_Term('power'), null);
$query->addTerm(new Zend_Search_Lucene_Index_Term('java'), false);
$hits = $index->find($query);
The second parameter controls the modifier: true for required, false for prohibited and null for no modifer. In this the
query will find all documents that contain the word ???php??? and may contain the word ???power??? but do not contain the
word ???java???.
Wildcard Query Wildcard queries are used for search for a set of terms where only some of the letters are known.
Example search: super*
$term = new Zend_Search_Lucene_Index_Term('super*');
$query = new Zend_Search_Lucene_Search_Query_Wildcard($term);
$hits = $index->find($query);
As you can see, the standard Zend_Search_Lucene_Index_Term object is used and then passed to a
Zend_Search_Lucene_Search_Query_Wildcard object to ensure that the * (or ?) is interpreted correctly.


Pages:
197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221
kasyno kino azjatyckie bwin out of home advertising Bukmacher pinacle