/**
  * Tests the MultiMatch Query.
  */
 public function testMultiMatchQuery()
 {
     $this->specify('multiMatch query was created', function () {
         $query = $this->queryBuilder->createMultiMatchQuery();
         verify($query)->isInstanceOf('\\Nord\\Lumen\\Elasticsearch\\Search\\Query\\FullText\\MultiMatchQuery');
     });
     $this->specify('multiMatch query format', function () {
         $query = $this->queryBuilder->createMultiMatchQuery();
         $query->setFields(['field1', 'field2'])->setValue('value');
         $array = $query->toArray();
         verify($array)->equals(['multi_match' => ['query' => 'value', 'fields' => ['field1', 'field2']]]);
     });
     $this->specify('multiMatch query format with tie_breaker', function () {
         $query = $this->queryBuilder->createMultiMatchQuery();
         $query->setTieBreaker(0.3)->setFields(['field1', 'field2'])->setValue('value');
         $array = $query->toArray();
         verify($array)->equals(['multi_match' => ['query' => 'value', 'fields' => ['field1', 'field2'], 'tie_breaker' => 0.3]]);
     });
     $this->specify('multiMatch query format with type', function () {
         $query = $this->queryBuilder->createMultiMatchQuery();
         $query->setFields(['field1', 'field2'])->setValue('value')->setType(\Nord\Lumen\Elasticsearch\Search\Query\FullText\MultiMatchQuery::TYPE_CROSS_FIELDS);
         $array = $query->toArray();
         verify($array)->equals(['multi_match' => ['query' => 'value', 'fields' => ['field1', 'field2'], 'type' => 'cross_fields']]);
     });
 }
 /**
  * Tests the HasChild Query.
  */
 public function testHasChildQuery()
 {
     $this->specify('hasChild query was created', function () {
         $query = $this->queryBuilder->createHasChildQuery();
         verify($query)->isInstanceOf('\\Nord\\Lumen\\Elasticsearch\\Search\\Query\\Joining\\HasChildQuery');
     });
     $this->specify('hasChild query format', function () {
         $query = $this->queryBuilder->createHasChildQuery();
         $query->setType('doc')->setQuery($this->queryBuilder->createBoolQuery()->addMust($this->queryBuilder->createTermsQuery()->setField('id')->setValues(['ID1', 'ID2'])));
         $array = $query->toArray();
         verify($array)->equals(['has_child' => ['type' => 'doc', 'query' => ['bool' => ['must' => [['terms' => ['id' => ['ID1', 'ID2']]]]]]]]);
     });
     $this->specify('hasChild query format with score_mode', function () {
         $query = $this->queryBuilder->createHasChildQuery();
         $query->setType('doc')->setQuery($this->queryBuilder->createBoolQuery()->addMust($this->queryBuilder->createTermsQuery()->setField('id')->setValues(['ID1', 'ID2'])))->setScoreMode(\Nord\Lumen\Elasticsearch\Search\Query\Joining\HasChildQuery::SCORE_MODE_SUM);
         $array = $query->toArray();
         verify($array)->equals(['has_child' => ['type' => 'doc', 'query' => ['bool' => ['must' => [['terms' => ['id' => ['ID1', 'ID2']]]]]], 'score_mode' => 'sum']]);
     });
     $this->specify('hasChild query format with min_children', function () {
         $query = $this->queryBuilder->createHasChildQuery();
         $query->setType('doc')->setQuery($this->queryBuilder->createBoolQuery()->addMust($this->queryBuilder->createTermsQuery()->setField('id')->setValues(['ID1', 'ID2'])))->setMinChildren(2);
         $array = $query->toArray();
         verify($array)->equals(['has_child' => ['type' => 'doc', 'query' => ['bool' => ['must' => [['terms' => ['id' => ['ID1', 'ID2']]]]]], 'min_children' => 2]]);
     });
     $this->specify('hasChild query format with max_children', function () {
         $query = $this->queryBuilder->createHasChildQuery();
         $query->setType('doc')->setQuery($this->queryBuilder->createBoolQuery()->addMust($this->queryBuilder->createTermsQuery()->setField('id')->setValues(['ID1', 'ID2'])))->setMaxChildren(10);
         $array = $query->toArray();
         verify($array)->equals(['has_child' => ['type' => 'doc', 'query' => ['bool' => ['must' => [['terms' => ['id' => ['ID1', 'ID2']]]]]], 'max_children' => 10]]);
     });
 }
 /**
  * Tests the Bool Query.
  */
 public function testBoolQuery()
 {
     $this->specify('bool query was created', function () {
         $query = $this->queryBuilder->createBoolQuery();
         verify($query)->isInstanceOf('\\Nord\\Lumen\\Elasticsearch\\Search\\Query\\Compound\\BoolQuery');
     });
     $this->specify('bool query with leaf queries ', function () {
         $query = $this->queryBuilder->createBoolQuery();
         $query->addMust($this->queryBuilder->createTermQuery()->setField('field1')->setValue('value1'));
         $query->addFilter($this->queryBuilder->createTermQuery()->setField('field2')->setValue('value2'));
         $query->addMustNot($this->queryBuilder->createRangeQuery()->setField('field3')->setGreaterThanOrEquals(1)->setLessThanOrEquals(2));
         $query->addShould($this->queryBuilder->createTermQuery()->setField('field4')->setValue('value3'));
         $query->addShould($this->queryBuilder->createTermQuery()->setField('field4')->setValue('value4'));
         $array = $query->toArray();
         verify($array)->equals(['bool' => ['must' => [['term' => ['field1' => 'value1']]], 'filter' => [['term' => ['field2' => 'value2']]], 'must_not' => [['range' => ['field3' => ['gte' => 1, 'lte' => 2]]]], 'should' => [['term' => ['field4' => 'value3']], ['term' => ['field4' => 'value4']]]]]);
     });
 }