Elastica\Query\FunctionScore::toArray PHP Method

toArray() public method

public toArray ( ) : array
return array
    public function toArray()
    {
        if (sizeof($this->_functions)) {
            $this->setParam('functions', $this->_functions);
        }
        return parent::toArray();
    }

Usage Example

 /**
  * @group functional
  */
 public function testSetMinScore()
 {
     $expected = array('function_score' => array('min_score' => 0.8, 'functions' => array(array('gauss' => array('price' => array('origin' => 0, 'scale' => 10))))));
     $query = new FunctionScore();
     $query->addDecayFunction(FunctionScore::DECAY_GAUSS, 'price', 0, 10);
     $returnedValue = $query->setMinScore(0.8);
     $this->assertEquals($expected, $query->toArray());
     $this->assertInstanceOf('Elastica\\Query\\FunctionScore', $returnedValue);
     $response = $this->_getIndexForTest()->search($query);
     $results = $response->getResults();
     $this->assertCount(1, $results);
     $this->assertEquals(1, $results[0]->getId());
 }
All Usage Examples Of Elastica\Query\FunctionScore::toArray