コード例 #1
0
ファイル: CommonTest.php プロジェクト: bungkoko/Elastica
 /**
  * @group unit
  */
 public function testToArray()
 {
     $query = new Common('body', 'test query', 0.001);
     $query->setLowFrequencyOperator(Common::OPERATOR_AND);
     $expected = array('common' => array('body' => array('query' => 'test query', 'cutoff_frequency' => 0.001, 'low_freq_operator' => 'and')));
     $this->assertEquals($expected, $query->toArray());
 }
コード例 #2
0
 /**
  * Finds all documents matching the query but groups common words,
  * i.e. the, and runs them after the initial query for more efficiency.
  *
  * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-common-terms-query.html
  *
  * @param string $field
  * @param string $query
  * @param float $cutOff
  * @param int|bool $minimumMatch
  * @return Query
  */
 public function common($field, $query, $cutOff = 0.001, $minimumMatch = false)
 {
     $common = new Common($field, $query, $cutOff);
     if ($minimumMatch) {
         $common->setMinimumShouldMatch($minimumMatch);
     }
     $query = $this->newQuery($common);
     $this->query[] = $query;
     return $query;
 }