addQuery() public method

Add a query to a multi-query batch. Returns index into results array from runQueries() call
public addQuery ( string $query, string $index = '*', string $comment = '' ) : integer
$query string
$index string
$comment string
return integer Results array index.
 /**
  * Adds a query to a multi-query batch
  *
  * @param string $query   Search query
  * @param array  $indexes Index list to perform the search
  *
  * @throws EmptyIndexException If $indexes is empty
  */
 public function addQuery($query, array $indexes)
 {
     if (empty($indexes)) {
         throw new EmptyIndexException('Try to search with empty indexes');
     }
     $this->sphinx->addQuery($query, implode(' ', $indexes));
 }
Esempio n. 2
0
 public function testAddQueryWithError()
 {
     $sphinx = new SphinxClient();
     $sphinx->setMatchMode(SphinxClient::SPH_MATCH_EXTENDED);
     $sphinx->addQuery('@ccc');
     $sphinx->addQuery('dddd');
     $results = $sphinx->runQueries();
     $this->assertEquals(count($results), 2);
     $this->assertGreaterThan(0, strlen($results[0]['error']));
 }
Esempio n. 3
0
 /**
  * Add a query to Sphinx, to be run as part of a batch.
  *
  * @param MultiFieldQuery|string $query Sphinx query to be computed.
  * @param string $index (Optional) Limit Sphinx search to this index.
  * @param string $comment (Optional) Comment associated with this query.
  * @return integer Number of requests.
  */
 public function addQuery($query, $index = null, $comment = '')
 {
     $index = $index ?: $this->_default_index;
     if ($query instanceof MultiFieldQuery) {
         if ($this->getFiltering()) {
             $this->setFilters($query);
         }
         $result = parent::addQuery($query->toSphinx($this->getFiltering()), $index, $comment);
         if ($this->getFiltering()) {
             $this->resetFilters();
         }
     } else {
         $result = parent::addQuery($query, $index, $comment);
     }
     return $result;
 }
 /**
  * {@inheritdoc}
  */
 public function addQuery($query, $index = '*', $comment = '')
 {
     return $this->proxy->addQuery($query, $index, $comment);
 }