toArray() публичный Метод

public toArray ( ) : array
Результат array
Пример #1
0
 /**
  * @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());
 }
Пример #2
0
 /**
  * @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());
 }
 public function testScriptScore()
 {
     $scriptString = "_score * doc['price'].value";
     $script = new Script($scriptString);
     $query = new FunctionScore();
     $query->addScriptScoreFunction($script);
     $expected = array('function_score' => array('functions' => array(array('script_score' => array('script' => $scriptString)))));
     $this->assertEquals($expected, $query->toArray());
     $response = $this->type->search($query);
     $results = $response->getResults();
     // the document the highest price should be scored highest
     $result0 = $results[0]->getData();
     $this->assertEquals("Miller's Field", $result0['name']);
 }