1 | <?php |
---|
2 | /** |
---|
3 | * Copyright 2011 Bas de Nooijer. All rights reserved. |
---|
4 | * |
---|
5 | * Redistribution and use in source and binary forms, with or without |
---|
6 | * modification, are permitted provided that the following conditions are met: |
---|
7 | * |
---|
8 | * 1. Redistributions of source code must retain the above copyright notice, |
---|
9 | * this list of conditions and the following disclaimer. |
---|
10 | * |
---|
11 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
---|
12 | * this listof conditions and the following disclaimer in the documentation |
---|
13 | * and/or other materials provided with the distribution. |
---|
14 | * |
---|
15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS" |
---|
16 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
---|
17 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
---|
18 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
---|
19 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
---|
20 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
---|
21 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
---|
22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
---|
23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
---|
24 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
---|
25 | * POSSIBILITY OF SUCH DAMAGE. |
---|
26 | * |
---|
27 | * The views and conclusions contained in the software and documentation are |
---|
28 | * those of the authors and should not be interpreted as representing official |
---|
29 | * policies, either expressed or implied, of the copyright holder. |
---|
30 | * |
---|
31 | * @copyright Copyright 2011 Bas de Nooijer <solarium@raspberry.nl> |
---|
32 | * @license http://github.com/basdenooijer/solarium/raw/master/COPYING |
---|
33 | * @link http://www.solarium-project.org/ |
---|
34 | * |
---|
35 | * @package Solarium |
---|
36 | * @subpackage Query |
---|
37 | */ |
---|
38 | |
---|
39 | /** |
---|
40 | * Suggester Query |
---|
41 | * |
---|
42 | * Can be used for an autocomplete feature. See http://wiki.apache.org/solr/Suggester for more info. |
---|
43 | * |
---|
44 | * @package Solarium |
---|
45 | * @subpackage Query |
---|
46 | */ |
---|
47 | class Solarium_Query_Suggester extends Solarium_Query |
---|
48 | { |
---|
49 | |
---|
50 | /** |
---|
51 | * Get type for this query |
---|
52 | * |
---|
53 | * @return string |
---|
54 | */ |
---|
55 | public function getType() |
---|
56 | { |
---|
57 | return Solarium_Client::QUERYTYPE_SUGGESTER; |
---|
58 | } |
---|
59 | |
---|
60 | /** |
---|
61 | * Default options |
---|
62 | * |
---|
63 | * @var array |
---|
64 | */ |
---|
65 | protected $_options = array( |
---|
66 | 'handler' => 'suggest', |
---|
67 | 'resultclass' => 'Solarium_Result_Suggester', |
---|
68 | 'termclass' => 'Solarium_Result_Suggester_Term', |
---|
69 | ); |
---|
70 | |
---|
71 | /** |
---|
72 | * Set query option |
---|
73 | * |
---|
74 | * Query to spellcheck |
---|
75 | * |
---|
76 | * @param string $query |
---|
77 | * @return self Provides fluent interface |
---|
78 | */ |
---|
79 | public function setQuery($query) |
---|
80 | { |
---|
81 | return $this->_setOption('query', $query); |
---|
82 | } |
---|
83 | |
---|
84 | /** |
---|
85 | * Get query option |
---|
86 | * |
---|
87 | * @return string|null |
---|
88 | */ |
---|
89 | public function getQuery() |
---|
90 | { |
---|
91 | return $this->getOption('query'); |
---|
92 | } |
---|
93 | |
---|
94 | /** |
---|
95 | * Set dictionary option |
---|
96 | * |
---|
97 | * The name of the dictionary to use |
---|
98 | * |
---|
99 | * @param string $dictionary |
---|
100 | * @return self Provides fluent interface |
---|
101 | */ |
---|
102 | public function setDictionary($dictionary) |
---|
103 | { |
---|
104 | return $this->_setOption('dictionary', $dictionary); |
---|
105 | } |
---|
106 | |
---|
107 | /** |
---|
108 | * Get dictionary option |
---|
109 | * |
---|
110 | * @return string|null |
---|
111 | */ |
---|
112 | public function getDictionary() |
---|
113 | { |
---|
114 | return $this->getOption('dictionary'); |
---|
115 | } |
---|
116 | |
---|
117 | /** |
---|
118 | * Set count option |
---|
119 | * |
---|
120 | * The maximum number of suggestions to return |
---|
121 | * |
---|
122 | * @param int $count |
---|
123 | * @return self Provides fluent interface |
---|
124 | */ |
---|
125 | public function setCount($count) |
---|
126 | { |
---|
127 | return $this->_setOption('count', $count); |
---|
128 | } |
---|
129 | |
---|
130 | /** |
---|
131 | * Get count option |
---|
132 | * |
---|
133 | * @return int|null |
---|
134 | */ |
---|
135 | public function getCount() |
---|
136 | { |
---|
137 | return $this->getOption('count'); |
---|
138 | } |
---|
139 | |
---|
140 | /** |
---|
141 | * Set onlyMorePopular option |
---|
142 | * |
---|
143 | * Only return suggestions that result in more hits for the query than the existing query |
---|
144 | * |
---|
145 | * @param boolean $onlyMorePopular |
---|
146 | * @return self Provides fluent interface |
---|
147 | */ |
---|
148 | public function setOnlyMorePopular($onlyMorePopular) |
---|
149 | { |
---|
150 | return $this->_setOption('onlymorepopular', $onlyMorePopular); |
---|
151 | } |
---|
152 | |
---|
153 | /** |
---|
154 | * Get onlyMorePopular option |
---|
155 | * |
---|
156 | * @return boolean|null |
---|
157 | */ |
---|
158 | public function getOnlyMorePopular() |
---|
159 | { |
---|
160 | return $this->getOption('onlymorepopular'); |
---|
161 | } |
---|
162 | |
---|
163 | /** |
---|
164 | * Set collate option |
---|
165 | * |
---|
166 | * @param boolean $collate |
---|
167 | * @return self Provides fluent interface |
---|
168 | */ |
---|
169 | public function setCollate($collate) |
---|
170 | { |
---|
171 | return $this->_setOption('collate', $collate); |
---|
172 | } |
---|
173 | |
---|
174 | /** |
---|
175 | * Get collate option |
---|
176 | * |
---|
177 | * @return boolean|null |
---|
178 | */ |
---|
179 | public function getCollate() |
---|
180 | { |
---|
181 | return $this->getOption('collate'); |
---|
182 | } |
---|
183 | |
---|
184 | |
---|
185 | } |
---|