protected function formatResult(Result $result, $showField, $showSource, $showId, $explain) { $source = $result->getSource(); if ($showField) { $toString = isset($source[$showField]) ? $source[$showField] : '-'; } else { $toString = reset($source); } $string = sprintf('[%0.2f] %s', $result->getScore(), var_export($toString, true)); if ($showSource) { $string = sprintf('%s %s', $string, json_encode($source)); } if ($showId) { $string = sprintf('{%s} %s', $result->getId(), $string); } if ($explain) { $string = sprintf('%s %s', $string, json_encode($result->getExplanation())); } return $string; }
/** * * @return integer */ public function getScore() { return $this->elasticaResult->getScore(); }