12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- <?php
- namespace Mall\Framework\SearchClient\DSL;
- class Query {
- protected $term = null;
-
- protected $range;
- protected $prefix = null;
- protected $wildcard = null;
- protected $matchAll = null;
- protected $queryString = null;
- protected $bool = null;
- protected $disMax = null;
- protected $constantScore = null;
- protected $filteredQuery = null;
- public function __construct(array $options=array()) {
- }
-
- public function term($term, $field=false) {
- $this->term = ($field)
- ? array($field => $term)
- : $term;
- return $this;
- }
-
- public function wildcard($val, $field=false) {
- $this->wildcard = ($field)
- ? array($field => $val)
- : $val;
- return $this;
- }
-
-
- public function range(array $options=array()) {
- $this->range = new RangeQuery($options);
- return $this->range;
- }
-
- public function build() {
- $built = array();
- if ($this->term)
- $built['term'] = $this->term;
- elseif ($this->range)
- $built['range'] = $this->range->build();
- elseif ($this->wildcard)
- $built['wildcard'] = $this->wildcard;
- return $built;
- }
- }
|