/**
  * Adds this query to the SphinxClient $sphinx
  *
  * Adding the query resets the passed SphinxClient so that no existing
  * filters or group bys or sort order etc are inherited by this query.
  * The query details are then injected into Sphinx, and the resulting
  * id passed back to this query allowing the results to be mapped to
  * the query.
  *
  * @param \SphinxClient $sphinx
  *
  * @return $this
  */
 public function bindToSphinx(\SphinxClient $sphinx)
 {
     $sphinx->resetFilters();
     $sphinx->resetGroupBy();
     $sphinx->setRankingMode($this->rankingMode);
     if ($this->groupBy instanceof GroupBy) {
         $this->groupBy->bindToSphinx($sphinx);
     }
     $this->sortBy->bindToSphinx($sphinx);
     $this->limits->bindToSphinx($sphinx);
     /* @var FilterInterface $filter */
     foreach ($this->filters as $filter) {
         $filter->bindToSphinx($sphinx);
     }
     if ($this->builder instanceof Builder && !$this->query) {
         $this->query = $this->builder->getQuery();
     }
     $this->id = $sphinx->addQuery($this->query, $this->index->getIndexName());
     return $this;
 }
예제 #2
0
 public function fetch()
 {
     if (!class_exists('SphinxClient')) {
         return false;
     }
     $s = new SphinxClient();
     $s->setServer($this->_sphinxHost, $this->_sphinxPort);
     if (count($this->_arrSearchOutRangeColumnMinMax) > 0) {
         foreach ($this->_arrSearchOutRangeColumnMinMax as $value) {
             $d = explode(',', $value);
             $s->setFilterRange($d[0], $d[1], $d[2], true);
         }
     }
     if (count($this->_arrSearchInRangeColumnMinMax) > 0) {
         foreach ($this->_arrSearchInRangeColumnMinMax as $value) {
             $d = explode(',', $value);
             $s->setFilterRange($d[0], $d[1], $d[2], false);
         }
     }
     $s->setConnectTimeout($this->_connectTimeout);
     $s->setMaxQueryTime($this->{$_maxquerytime});
     //            $s->setRetries ( int $this->retriesCount , int $this->retriesDelay  );
     //
     $s->setMatchMode($this->searchMode);
     $s->setFieldWeights($this->_fieldweights);
     //            $s->setFilter ( string $attribute , array $values [, bool $exclude = false ] );
     //            $s->setFilterFloatRange ( string $attribute , float $min , float $max [, bool $exclude = false ] );
     //            $s->setFilterRange ( string $attribute , int $min , int $max [, bool $exclude = false ] );
     //            $s->setGeoAnchor ( string $attrlat , string $attrlong , float $latitude , float $longitude );
     //            $s->setGroupBy ( string $attribute , int $func [, string $groupsort = "@group desc" ] );
     //            $s->setGroupDistinct ( string $attribute );
     //            $s->setIDRange ( int $min , int $max );
     $s->setIndexWeights($this->_arrIndexweights);
     //            $s->setLimits ( int $offset , int $limit [, int $max_matches = 0 [, int $cutoff = 0 ]] );
     $s->setMatchMode($this->searchMode);
     //            $s->setOverride ( string $attribute , int $type , array $values );
     $s->setRankingMode($this->rankMode);
     //            $s->setSelect ( string $clause );
     //            $s->setSortMode ( int $mode [, string $sortby ] );
     return $s->query($this->_query);
 }
예제 #3
0
 /**
  * @brief reset search criteria to default
  * @details reset conditions and set default search options
  */
 public function resetCriteria()
 {
     if (is_object($this->criteria)) {
         $this->lastCriteria = clone $this->criteria;
     } else {
         $this->lastCriteria = new ESphinxCriteria();
     }
     $this->criteria = new ESphinxCriteria();
     $this->criteria->query = '';
     $this->client->resetFilters();
     $this->client->resetGroupBy();
     $this->client->setArrayResult(false);
     $this->client->setMatchMode($this->matchMode);
     $this->client->setRankingMode($this->rankMode);
     $this->client->setSortMode(SPH_SORT_RELEVANCE, '@relevance DESC');
     $this->client->setLimits(0, 1000000, 2000);
     if (!empty($this->fieldWeights)) {
         $this->client->setFieldWeights($this->fieldWeights);
     }
 }