/**
* @group functional
*/
public function testFieldValueFactor()
{
$this->_checkVersion('1.6');
$expected = array('function_score' => array('functions' => array(array('field_value_factor' => array('field' => 'popularity', 'factor' => 1.2, 'modifier' => 'sqrt', 'missing' => 0.1)))));
$query = new FunctionScore();
$query->addFieldValueFactorFunction('popularity', 1.2, FunctionScore::FIELD_VALUE_FACTOR_MODIFIER_SQRT, 0.1);
$this->assertEquals($expected, $query->toArray());
$response = $this->_getIndexForTest()->search($query);
$results = $response->getResults();
$this->assertCount(2, $results);
$this->assertEquals(2, $results[0]->getId());
}