/** * @group unit */ public function testDecayWeight() { $priceOrigin = 0; $locationScale = '2mi'; $priceScale = 9.25; $query = new FunctionScore(); $childQuery = new MatchAll(); $query->setQuery($childQuery); $query->addDecayFunction(FunctionScore::DECAY_GAUSS, 'location', $this->locationOrigin, $locationScale, null, null, 0.5); $query->addDecayFunction(FunctionScore::DECAY_GAUSS, 'price', $priceOrigin, $priceScale, null, null, 2); $expected = array('function_score' => array('query' => $childQuery->toArray(), 'functions' => array(array('gauss' => array('location' => array('origin' => $this->locationOrigin, 'scale' => $locationScale)), 'weight' => 0.5), array('gauss' => array('price' => array('origin' => $priceOrigin, 'scale' => $priceScale)), 'weight' => 2)))); $this->assertEquals($expected, $query->toArray()); }