1 | <?php |
||
19 | class Search |
||
20 | { |
||
21 | /** |
||
22 | * @var Index $index |
||
23 | */ |
||
24 | protected $index; |
||
25 | |||
26 | /** |
||
27 | * @var Query $query |
||
28 | */ |
||
29 | protected $query; |
||
30 | |||
31 | /** |
||
32 | * @var string|boolean $path |
||
33 | */ |
||
34 | private $path; |
||
35 | |||
36 | /** |
||
37 | * @var int $limit |
||
38 | */ |
||
39 | private $limit = 25; |
||
40 | |||
41 | /** |
||
42 | * @var int $offset |
||
43 | */ |
||
44 | private $offset = 0; |
||
45 | |||
46 | /** |
||
47 | * @var Boolean |
||
48 | */ |
||
49 | private static $boolean; |
||
50 | |||
51 | /** |
||
52 | * Search constructor. |
||
53 | * |
||
54 | * @param Index $index |
||
55 | * @param Query $query |
||
56 | */ |
||
57 | 32 | public function __construct(Index $index, Query $query) |
|
63 | |||
64 | /** |
||
65 | * @param $name |
||
66 | * @param $arguments |
||
67 | * @return $this |
||
68 | * @throws \BadMethodCallException |
||
69 | */ |
||
70 | 2 | public function __call($name, $arguments) |
|
79 | |||
80 | /** |
||
81 | * @param integer $limit |
||
82 | * @return $this |
||
83 | */ |
||
84 | 1 | public function limit($limit) |
|
89 | |||
90 | /** |
||
91 | * @param integer $offset |
||
92 | * @return $this |
||
93 | */ |
||
94 | 1 | public function offset($offset) |
|
99 | |||
100 | /** |
||
101 | * @param bool|string $path |
||
102 | * @return $this |
||
103 | */ |
||
104 | 21 | public function path($path = false) |
|
109 | |||
110 | /** |
||
111 | * @param $string |
||
112 | * @return $this |
||
113 | */ |
||
114 | 1 | public function raw($string) |
|
119 | |||
120 | /** |
||
121 | * @param $string |
||
122 | * @param null|string $field |
||
123 | * @param null $offsets |
||
124 | * @return $this |
||
125 | * @return $this |
||
126 | */ |
||
127 | 2 | public function phrase($string, $field = null, $offsets = null) |
|
132 | |||
133 | /** |
||
134 | * @param $string |
||
135 | * @param null|string $field |
||
136 | * @return $this |
||
137 | */ |
||
138 | 1 | public function fuzzy($string, $field = null) |
|
143 | |||
144 | /** |
||
145 | * @param $string |
||
146 | * @param null|string $field |
||
147 | * @return Term |
||
148 | */ |
||
149 | 4 | protected function indexTerm($string, $field = null) |
|
153 | |||
154 | /** |
||
155 | * @param $string |
||
156 | * @param null|string $field |
||
157 | * @return $this |
||
158 | */ |
||
159 | 1 | public function wildcard($string, $field = null) |
|
164 | |||
165 | /** |
||
166 | * Where |
||
167 | * |
||
168 | * A helper method to access phrase or to pass multiple fields. Phrase doesn't "match" exactly and |
||
169 | * allows searching within the text field rather than matching the whole string. |
||
170 | * |
||
171 | * @param boolean|$string |
||
172 | * @param null|string $field |
||
173 | * @return $this|bool |
||
174 | */ |
||
175 | 2 | public function where($string, $field = null) |
|
183 | |||
184 | /** |
||
185 | * Match |
||
186 | * |
||
187 | * Provides an exact pattern match. |
||
188 | * |
||
189 | * @param $string |
||
190 | * @param null $field |
||
191 | * @return $this |
||
192 | */ |
||
193 | 2 | public function match($string, $field = null) |
|
198 | |||
199 | /** |
||
200 | * @param array $terms |
||
201 | * @return $this |
||
202 | */ |
||
203 | 1 | public function multiTerm(array $terms) |
|
214 | |||
215 | /** |
||
216 | * @param string $string |
||
217 | * @param array $array |
||
218 | * @return mixed |
||
219 | */ |
||
220 | 1 | private function mapWhereArray($string, array $array) |
|
229 | |||
230 | /** |
||
231 | * @param string $string |
||
232 | * @param string|null $field |
||
233 | * @return QueryTerm |
||
234 | */ |
||
235 | 3 | public function term($string, $field = null) |
|
239 | |||
240 | /** |
||
241 | * @return mixed |
||
242 | */ |
||
243 | 2 | public function hits() |
|
249 | |||
250 | /** |
||
251 | * Slice |
||
252 | * |
||
253 | * This may look nasty, but there really isn't another way of offsetting results Lucene, and nor would |
||
254 | * you want to really, that's not what it's designed for. It will be quick up to a thousand and after |
||
255 | * that you should be asking the user to "refine their search". |
||
256 | * |
||
257 | * @param mixed $hits |
||
258 | * @return array |
||
259 | */ |
||
260 | 2 | public function slice($hits) |
|
264 | |||
265 | /** |
||
266 | * @param array|QueryHit $array |
||
267 | * @return mixed |
||
268 | */ |
||
269 | 3 | private function mapIds($array) |
|
278 | |||
279 | /** |
||
280 | * @return mixed |
||
281 | */ |
||
282 | 1 | public static function getLastQuery() |
|
286 | } |
||
287 |