cpliakas /
psolr
This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | |||
| 3 | namespace PSolr\Request; |
||
| 4 | |||
| 5 | /** |
||
| 6 | * @see http://wiki.apache.org/solr/SimpleFacetParameters |
||
| 7 | */ |
||
| 8 | class Facet extends SolrRequest implements ComponentInterface |
||
| 9 | { |
||
| 10 | // Values for facet.sort |
||
| 11 | const SORT_COUNT = 'count'; |
||
| 12 | const SORT_INDEX = 'index'; |
||
| 13 | |||
| 14 | // Values for facet.method |
||
| 15 | const METHOD_ENUMERATE = 'enum'; |
||
| 16 | const METHOD_FIELD_CACHE = 'fc'; |
||
| 17 | const METHOD_FIELD_CACHE_PER_SEGMENT = 'fcs'; |
||
| 18 | |||
| 19 | // Values for facet.date.other, facet.range.other |
||
| 20 | const COUNT_BEFORE = 'before'; |
||
| 21 | const COUNT_AFTER = 'after'; |
||
| 22 | const COUNT_BETWEEN = 'between'; |
||
| 23 | const COUNT_NONE = 'none'; |
||
| 24 | const COUNT_ALL = 'all'; |
||
| 25 | |||
| 26 | // Values for facet.date.include, facet.range.include |
||
| 27 | const INCLUDE_LOWER = 'lower'; |
||
| 28 | const INCLUDE_UPPER = 'upper'; |
||
| 29 | const INCLUDE_EDGE = 'edge'; |
||
| 30 | const INCLUDE_OUTER = 'outer'; |
||
| 31 | const INCLUDE_ALL = 'all'; |
||
| 32 | |||
| 33 | /** |
||
| 34 | * {@inheritDoc} |
||
| 35 | */ |
||
| 36 | public function preMergeParams(SolrRequest $request) {} |
||
| 37 | |||
| 38 | /** |
||
| 39 | * {@inheritDoc} |
||
| 40 | */ |
||
| 41 | public function init() |
||
| 42 | { |
||
| 43 | $this->facet(); |
||
| 44 | } |
||
| 45 | |||
| 46 | /** |
||
| 47 | * Helper function that builds a facet param based on whether it is global |
||
| 48 | * or per-field. If the field is null, the param is global. |
||
| 49 | * |
||
| 50 | * @param string $facetParam |
||
| 51 | * @param string|null $field |
||
| 52 | * |
||
| 53 | * @return string |
||
| 54 | * |
||
| 55 | * @see http://wiki.apache.org/solr/SimpleFacetParameters#Parameters |
||
| 56 | */ |
||
| 57 | public function buildParam($facetParam, $field) |
||
| 58 | { |
||
| 59 | $param = ''; |
||
| 60 | |||
| 61 | // Parameter is per-field |
||
| 62 | if ($field !== null) { |
||
| 63 | $param .= 'f.' . $field . '.'; |
||
| 64 | } |
||
| 65 | |||
| 66 | $param .= $facetParam; |
||
| 67 | return $param; |
||
| 68 | } |
||
| 69 | |||
| 70 | /** |
||
| 71 | * @param bool $facet |
||
| 72 | * |
||
| 73 | * @return \Psolr\Component\Facet |
||
| 74 | * |
||
| 75 | * @see http://wiki.apache.org/solr/SimpleFacetParameters#facet |
||
| 76 | */ |
||
| 77 | public function facet($facet = true) |
||
|
0 ignored issues
–
show
Coding Style
Best Practice
introduced
by
Loading history...
|
|||
| 78 | { |
||
| 79 | return $this->set('facet', (bool) $facet); |
||
| 80 | } |
||
| 81 | |||
| 82 | /** |
||
| 83 | * @param string $query |
||
| 84 | * |
||
| 85 | * @return \Psolr\Component\Facet |
||
| 86 | * |
||
| 87 | * @see http://wiki.apache.org/solr/SimpleFacetParameters#facet.query_:_Arbitrary_Query_Faceting |
||
| 88 | */ |
||
| 89 | public function addQuery($query) |
||
| 90 | { |
||
| 91 | return $this->add('facet.query', $query); |
||
| 92 | } |
||
| 93 | |||
| 94 | /** |
||
| 95 | * @param string $field |
||
| 96 | * |
||
| 97 | * @return \Psolr\Component\Facet |
||
| 98 | * |
||
| 99 | * @see http://wiki.apache.org/solr/SimpleFacetParameters#facet.field |
||
| 100 | */ |
||
| 101 | public function addField($field) |
||
| 102 | { |
||
| 103 | return $this->add('facet.field', $field); |
||
| 104 | } |
||
| 105 | |||
| 106 | /** |
||
| 107 | * @param string $prefix |
||
| 108 | * @param string|null $field |
||
| 109 | * |
||
| 110 | * @return \PSolr\Request\Facet |
||
| 111 | * |
||
| 112 | * @see http://wiki.apache.org/solr/SimpleFacetParameters#facet.prefix |
||
| 113 | */ |
||
| 114 | public function setPrefix($prefix, $field = null) |
||
| 115 | { |
||
| 116 | $param = $this->buildParam('facet.prefix', $field); |
||
| 117 | return $this->set($param, $prefix); |
||
| 118 | } |
||
| 119 | |||
| 120 | /** |
||
| 121 | * @param string $sort |
||
| 122 | * @param string|null $field |
||
| 123 | * |
||
| 124 | * @return \PSolr\Request\Facet |
||
| 125 | * |
||
| 126 | * @see http://wiki.apache.org/solr/SimpleFacetParameters#facet.sort |
||
| 127 | */ |
||
| 128 | public function setSort($sort, $field = null) |
||
| 129 | { |
||
| 130 | $param = $this->buildParam('facet.sort', $field); |
||
| 131 | return $this->set($param, $sort); |
||
| 132 | } |
||
| 133 | |||
| 134 | /** |
||
| 135 | * @param int $limit |
||
| 136 | * @param string|null $field |
||
| 137 | * |
||
| 138 | * @return \PSolr\Request\Facet |
||
| 139 | * |
||
| 140 | * @see http://wiki.apache.org/solr/SimpleFacetParameters#facet.limit |
||
| 141 | */ |
||
| 142 | public function setLimit($limit, $field = null) |
||
| 143 | { |
||
| 144 | $param = $this->buildParam('facet.limit', $field); |
||
| 145 | return $this->set($param, $limit); |
||
| 146 | } |
||
| 147 | |||
| 148 | /** |
||
| 149 | * @param int $offset |
||
| 150 | * @param string|null $field |
||
| 151 | * |
||
| 152 | * @return \PSolr\Request\Facet |
||
| 153 | * |
||
| 154 | * @see http://wiki.apache.org/solr/SimpleFacetParameters#facet.offset |
||
| 155 | */ |
||
| 156 | public function setOffset($offset, $field = null) |
||
| 157 | { |
||
| 158 | $param = $this->buildParam('facet.offset', $field); |
||
| 159 | return $this->set($param, $offset); |
||
| 160 | } |
||
| 161 | |||
| 162 | /** |
||
| 163 | * @param int $mincount |
||
| 164 | * @param string|null $field |
||
| 165 | * |
||
| 166 | * @return \PSolr\Request\Facet |
||
| 167 | * |
||
| 168 | * @see http://wiki.apache.org/solr/SimpleFacetParameters#facet.mincount |
||
| 169 | */ |
||
| 170 | public function setMincount($mincount, $field = null) |
||
| 171 | { |
||
| 172 | $param = $this->buildParam('facet.mincount', $field); |
||
| 173 | return $this->set($param, $mincount); |
||
| 174 | } |
||
| 175 | |||
| 176 | /** |
||
| 177 | * @param bool $missing |
||
| 178 | * @param string|null $field |
||
| 179 | * |
||
| 180 | * @return \PSolr\Request\Facet |
||
| 181 | * |
||
| 182 | * @see http://wiki.apache.org/solr/SimpleFacetParameters#facet.missing |
||
| 183 | */ |
||
| 184 | public function setMissing($missing, $field = null) |
||
| 185 | { |
||
| 186 | $param = $this->buildParam('facet.missing', $field); |
||
| 187 | return $this->set($param, (bool) $missing); |
||
| 188 | } |
||
| 189 | |||
| 190 | /** |
||
| 191 | * @param string $method |
||
| 192 | * @param string|null $field |
||
| 193 | * |
||
| 194 | * @return \PSolr\Request\Facet |
||
| 195 | * |
||
| 196 | * @see http://wiki.apache.org/solr/SimpleFacetParameters#facet.method |
||
| 197 | */ |
||
| 198 | public function setMethod($method, $field = null) |
||
| 199 | { |
||
| 200 | $param = $this->buildParam('facet.method', $field); |
||
| 201 | return $this->set($param, $method); |
||
| 202 | } |
||
| 203 | |||
| 204 | /** |
||
| 205 | * @param int $min |
||
| 206 | * @param string|null $field |
||
| 207 | * |
||
| 208 | * @return \PSolr\Request\Facet |
||
| 209 | * |
||
| 210 | * @see http://wiki.apache.org/solr/SimpleFacetParameters#facet.enum.cache.minDf |
||
| 211 | */ |
||
| 212 | public function setMinimumDocumentFrequency($min, $field = null) |
||
| 213 | { |
||
| 214 | $param = $this->buildParam('facet.enum.cache.minDf', $field); |
||
| 215 | return $this->set($param, $min); |
||
| 216 | } |
||
| 217 | |||
| 218 | /** |
||
| 219 | * @param int $threads |
||
| 220 | * @param string|null $field |
||
| 221 | * |
||
| 222 | * @return \PSolr\Request\Facet |
||
| 223 | * |
||
| 224 | * @see http://wiki.apache.org/solr/SimpleFacetParameters#facet.threads |
||
| 225 | */ |
||
| 226 | public function setThreads($threads, $field = null) |
||
| 227 | { |
||
| 228 | $param = $this->buildParam('facet.threads', $field); |
||
| 229 | return $this->set($param, $threads); |
||
| 230 | } |
||
| 231 | |||
| 232 | /** |
||
| 233 | * @param string $field |
||
| 234 | * |
||
| 235 | * @return \Psolr\Component\Facet |
||
| 236 | * |
||
| 237 | * @see http://wiki.apache.org/solr/SimpleFacetParameters#facet.date |
||
| 238 | */ |
||
| 239 | public function addDateField($field) |
||
| 240 | { |
||
| 241 | return $this->add('facet.date', $field); |
||
| 242 | } |
||
| 243 | |||
| 244 | /** |
||
| 245 | * @param string $start |
||
| 246 | * @param string|null $field |
||
| 247 | * |
||
| 248 | * @return \PSolr\Request\Facet |
||
| 249 | * |
||
| 250 | * @see http://wiki.apache.org/solr/SimpleFacetParameters#facet.date.start |
||
| 251 | * @see http://lucene.apache.org/solr/4_0_0/solr-core/org/apache/solr/util/DateMathParser.html |
||
| 252 | */ |
||
| 253 | public function setDateStart($start, $field = null) |
||
| 254 | { |
||
| 255 | $param = $this->buildParam('facet.date.start', $field); |
||
| 256 | return $this->set($param, $start); |
||
| 257 | } |
||
| 258 | |||
| 259 | /** |
||
| 260 | * @param string $end |
||
| 261 | * @param string|null $field |
||
| 262 | * |
||
| 263 | * @return \PSolr\Request\Facet |
||
| 264 | * |
||
| 265 | * @see http://wiki.apache.org/solr/SimpleFacetParameters#facet.date.end |
||
| 266 | * @see http://lucene.apache.org/solr/4_0_0/solr-core/org/apache/solr/util/DateMathParser.html |
||
| 267 | */ |
||
| 268 | public function setDateEnd($end, $field = null) |
||
| 269 | { |
||
| 270 | $param = $this->buildParam('facet.date.end', $field); |
||
| 271 | return $this->set($param, $end); |
||
| 272 | } |
||
| 273 | |||
| 274 | /** |
||
| 275 | * @param string $gap |
||
| 276 | * @param string|null $field |
||
| 277 | * |
||
| 278 | * @return \PSolr\Request\Facet |
||
| 279 | * |
||
| 280 | * @see http://wiki.apache.org/solr/SimpleFacetParameters#facet.date.gap |
||
| 281 | * @see http://lucene.apache.org/solr/4_0_0/solr-core/org/apache/solr/util/DateMathParser.html |
||
| 282 | */ |
||
| 283 | public function setDateGap($gap, $field = null) |
||
| 284 | { |
||
| 285 | $param = $this->buildParam('facet.date.gap', $field); |
||
| 286 | return $this->set($param, $gap); |
||
| 287 | } |
||
| 288 | |||
| 289 | /** |
||
| 290 | * @param bool $hardend |
||
| 291 | * @param string|null $field |
||
| 292 | * |
||
| 293 | * @return \PSolr\Request\Facet |
||
| 294 | * |
||
| 295 | * @see http://wiki.apache.org/solr/SimpleFacetParameters#facet.date.hardend |
||
| 296 | * @see http://lucene.apache.org/solr/4_0_0/solr-core/org/apache/solr/util/DateMathParser.html |
||
| 297 | */ |
||
| 298 | public function setDateHardened($hardend, $field = null) |
||
| 299 | { |
||
| 300 | $param = $this->buildParam('facet.date.hardend', $field); |
||
| 301 | return $this->set($param, (bool) $hardend); |
||
| 302 | } |
||
| 303 | |||
| 304 | /** |
||
| 305 | * @param string $other |
||
| 306 | * @param string|null $field |
||
| 307 | * |
||
| 308 | * @return \PSolr\Request\Facet |
||
| 309 | * |
||
| 310 | * @see http://wiki.apache.org/solr/SimpleFacetParameters#facet.date.other |
||
| 311 | * @see http://lucene.apache.org/solr/4_0_0/solr-core/org/apache/solr/util/DateMathParser.html |
||
| 312 | */ |
||
| 313 | public function setDateOther($other, $field = null) |
||
| 314 | { |
||
| 315 | $param = $this->buildParam('facet.date.other', $field); |
||
| 316 | return $this->set($param, $other); |
||
| 317 | } |
||
| 318 | |||
| 319 | /** |
||
| 320 | * @param string $include |
||
| 321 | * @param string|null $field |
||
| 322 | * |
||
| 323 | * @return \PSolr\Request\Facet |
||
| 324 | * |
||
| 325 | * @see http://wiki.apache.org/solr/SimpleFacetParameters#facet.date.include |
||
| 326 | * @see http://lucene.apache.org/solr/4_0_0/solr-core/org/apache/solr/util/DateMathParser.html |
||
| 327 | */ |
||
| 328 | public function setDateInclude($include, $field = null) |
||
| 329 | { |
||
| 330 | $param = $this->buildParam('facet.date.include', $field); |
||
| 331 | return $this->set($param, $include); |
||
| 332 | } |
||
| 333 | |||
| 334 | /** |
||
| 335 | * @param string $field |
||
| 336 | * |
||
| 337 | * @return \Psolr\Component\Facet |
||
| 338 | * |
||
| 339 | * @see http://wiki.apache.org/solr/SimpleFacetParameters#facet.range |
||
| 340 | */ |
||
| 341 | public function addRangeField($field) |
||
| 342 | { |
||
| 343 | return $this->add('facet.range', $field); |
||
| 344 | } |
||
| 345 | |||
| 346 | /** |
||
| 347 | * @param string $start |
||
| 348 | * @param string|null $field |
||
| 349 | * |
||
| 350 | * @return \PSolr\Request\Facet |
||
| 351 | * |
||
| 352 | * @see http://wiki.apache.org/solr/SimpleFacetParameters#facet.range.start |
||
| 353 | * @see http://lucene.apache.org/solr/4_0_0/solr-core/org/apache/solr/util/DateMathParser.html |
||
| 354 | */ |
||
| 355 | public function setRangeStart($start, $field = null) |
||
| 356 | { |
||
| 357 | $param = $this->buildParam('facet.range.start', $field); |
||
| 358 | return $this->set($param, $start); |
||
| 359 | } |
||
| 360 | |||
| 361 | /** |
||
| 362 | * @param string $end |
||
| 363 | * @param string|null $field |
||
| 364 | * |
||
| 365 | * @return \PSolr\Request\Facet |
||
| 366 | * |
||
| 367 | * @see http://wiki.apache.org/solr/SimpleFacetParameters#facet.range.end |
||
| 368 | * @see http://lucene.apache.org/solr/4_0_0/solr-core/org/apache/solr/util/DateMathParser.html |
||
| 369 | */ |
||
| 370 | public function setRangeEnd($end, $field = null) |
||
| 371 | { |
||
| 372 | $param = $this->buildParam('facet.range.end', $field); |
||
| 373 | return $this->set($param, $end); |
||
| 374 | } |
||
| 375 | |||
| 376 | /** |
||
| 377 | * @param string $gap |
||
| 378 | * @param string|null $field |
||
| 379 | * |
||
| 380 | * @return \PSolr\Request\Facet |
||
| 381 | * |
||
| 382 | * @see http://wiki.apache.org/solr/SimpleFacetParameters#facet.range.gap |
||
| 383 | * @see http://lucene.apache.org/solr/4_0_0/solr-core/org/apache/solr/util/DateMathParser.html |
||
| 384 | */ |
||
| 385 | public function setRangeGap($gap, $field = null) |
||
| 386 | { |
||
| 387 | $param = $this->buildParam('facet.range.gap', $field); |
||
| 388 | return $this->set($param, $gap); |
||
| 389 | } |
||
| 390 | |||
| 391 | /** |
||
| 392 | * @param bool $hardend |
||
| 393 | * @param string|null $field |
||
| 394 | * |
||
| 395 | * @return \PSolr\Request\Facet |
||
| 396 | * |
||
| 397 | * @see http://wiki.apache.org/solr/SimpleFacetParameters#facet.range.hardend |
||
| 398 | * @see http://lucene.apache.org/solr/4_0_0/solr-core/org/apache/solr/util/DateMathParser.html |
||
| 399 | */ |
||
| 400 | public function setRangeHardened($hardend, $field = null) |
||
| 401 | { |
||
| 402 | $param = $this->buildParam('facet.range.hardend', $field); |
||
| 403 | return $this->set($param, (bool) $hardend); |
||
| 404 | } |
||
| 405 | |||
| 406 | /** |
||
| 407 | * @param string $other |
||
| 408 | * @param string|null $field |
||
| 409 | * |
||
| 410 | * @return \PSolr\Request\Facet |
||
| 411 | * |
||
| 412 | * @see http://wiki.apache.org/solr/SimpleFacetParameters#facet.range.other |
||
| 413 | * @see http://lucene.apache.org/solr/4_0_0/solr-core/org/apache/solr/util/DateMathParser.html |
||
| 414 | */ |
||
| 415 | public function setRangeOther($other, $field = null) |
||
| 416 | { |
||
| 417 | $param = $this->buildParam('facet.range.other', $field); |
||
| 418 | return $this->set($param, $other); |
||
| 419 | } |
||
| 420 | |||
| 421 | /** |
||
| 422 | * @param string $include |
||
| 423 | * @param string|null $field |
||
| 424 | * |
||
| 425 | * @return \PSolr\Request\Facet |
||
| 426 | * |
||
| 427 | * @see http://wiki.apache.org/solr/SimpleFacetParameters#facet.range.include |
||
| 428 | * @see http://lucene.apache.org/solr/4_0_0/solr-core/org/apache/solr/util/DateMathParser.html |
||
| 429 | */ |
||
| 430 | public function setRangeInclude($include, $field = null) |
||
| 431 | { |
||
| 432 | $param = $this->buildParam('facet.range.include', $field); |
||
| 433 | return $this->set($param, $include); |
||
| 434 | } |
||
| 435 | |||
| 436 | /** |
||
| 437 | * @param string|array $fields |
||
| 438 | * |
||
| 439 | * @return \Psolr\Component\Facet |
||
| 440 | * |
||
| 441 | * @see http://wiki.apache.org/solr/SimpleFacetParameters#facet.pivot |
||
| 442 | */ |
||
| 443 | public function addPivot($fields) |
||
| 444 | { |
||
| 445 | return $this->add('facet.pivot', join(',', (array) $fields)); |
||
| 446 | } |
||
| 447 | |||
| 448 | /** |
||
| 449 | * @param int $min |
||
| 450 | * |
||
| 451 | * @return \Psolr\Component\Facet |
||
| 452 | * |
||
| 453 | * @see http://wiki.apache.org/solr/SimpleFacetParameters#facet.pivot.mincount |
||
| 454 | */ |
||
| 455 | public function setPivotMincount($min) |
||
| 456 | { |
||
| 457 | return $this->add('facet.mincount', $min); |
||
| 458 | } |
||
| 459 | } |
||
| 460 |