Elastica\Query\BoolQuery::addShould PHP Method

addShould() public method

Add should part to query.
public addShould ( Elastica\Query\AbstractQuery | array $args )
$args Elastica\Query\AbstractQuery | array Should query
    public function addShould($args)
    {
        return $this->_addQuery('should', $args);
    }

Usage Example

Exemplo n.º 1
0
 /**
  * Test to resolve the following issue.
  *
  * @link https://groups.google.com/forum/?fromgroups#!topic/elastica-php-client/zK_W_hClfvU
  *
  * @group unit
  */
 public function testToArrayStructure()
 {
     $boolQuery = new BoolQuery();
     $term1 = new Term();
     $term1->setParam('interests', 84);
     $term2 = new Term();
     $term2->setParam('interests', 92);
     $boolQuery->addShould($term1)->addShould($term2);
     $jsonString = '{"bool":{"should":[{"term":{"interests":84}},{"term":{"interests":92}}]}}';
     $this->assertEquals($jsonString, json_encode($boolQuery->toArray()));
 }
All Usage Examples Of Elastica\Query\BoolQuery::addShould