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