7 * This source file is subject to the new BSD license that is bundled
8 * with this package in the file LICENSE.txt.
9 * It is also available through the world-wide-web at this URL:
10 * http://framework.zend.com/license/new-bsd
11 * If you did not receive a copy of the license and are unable to
12 * obtain it through the world-wide-web, please send an email
13 * to license@zend.com so we can send you a copy immediately.
16 * @package Zend_Search_Lucene
18 * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
19 * @license http://framework.zend.com/license/new-bsd New BSD License
20 * @version $Id: Phrase.php 16971 2009-07-22 18:05:45Z mikaelkael $
23 /** Zend_Search_Lucene_Index_Term */
24 require_once 'Zend/Search/Lucene/Index/Term.php';
26 /** Zend_Search_Lucene_Search_QueryEntry */
27 require_once 'Zend/Search/Lucene/Search/QueryEntry.php';
29 /** Zend_Search_Lucene_Analysis_Analyzer */
30 require_once 'Zend/Search/Lucene/Analysis/Analyzer.php';
34 * @package Zend_Search_Lucene
36 * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
37 * @license http://framework.zend.com/license/new-bsd New BSD License
39 class Zend_Search_Lucene_Search_QueryEntry_Phrase extends Zend_Search_Lucene_Search_QueryEntry
57 * Proximity phrase query
61 private $_proximityQuery = false;
64 * Words distance, used for proximiti queries
68 private $_wordsDistance = 0;
74 * @param string $phrase
75 * @param string $field
77 public function __construct($phrase, $field)
79 $this->_phrase = $phrase;
80 $this->_field = $field;
84 * Process modifier ('~')
86 * @param mixed $parameter
88 public function processFuzzyProximityModifier($parameter = null)
90 $this->_proximityQuery = true;
92 if ($parameter !== null) {
93 $this->_wordsDistance = $parameter;
98 * Transform entry to a subquery
100 * @param string $encoding
101 * @return Zend_Search_Lucene_Search_Query
102 * @throws Zend_Search_Lucene_Search_QueryParserException
104 public function getQuery($encoding)
106 $query = new Zend_Search_Lucene_Search_Query_Preprocessing_Phrase($this->_phrase,
108 ($this->_field !== null)?
109 iconv($encoding, 'UTF-8', $this->_field) :
112 if ($this->_proximityQuery) {
113 $query->setSlop($this->_wordsDistance);
116 $query->setBoost($this->_boost);