getSource() public method

Returns the result source.
public getSource ( ) : array
return array Source data array
示例#1
0
 /**
  * {@inheritDoc}
  */
 public function toModel(Result $result, Model $model)
 {
     $exclude = ['location', 'full_address'];
     $filtered = array_diff_key($result->getSource(), array_flip($exclude));
     $model->exists = true;
     $model->id = $result->getId();
     $model->fill($filtered);
     return $model;
 }
 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;
 }
示例#3
0
 /**
  * @param  Result $authorObject
  * @return string
  */
 private function generateAuthorUrl(Result $authorObject)
 {
     $source = $authorObject->getSource();
     if (!empty($source['user'])) {
         return $this->router->generate('ojs_user_profile', ['slug' => $source['user']['username']], true);
     } else {
         if (!isset($source['articleAuthors'][0]['article'])) {
             return false;
         }
         $article = $source['articleAuthors'][0]['article'];
         if (!isset($article['issue']['id'])) {
             return false;
         }
         return $this->router->generate('ojs_article_page', ['slug' => $article['journal']['slug'], 'article_id' => $article['id'], 'issue_id' => $article['issue']['id'], 'publisher' => $article['journal']['publisher']['slug']], true);
     }
 }
 /**
  * Return _source
  * @return array
  */
 public function getSource()
 {
     return $this->elasticaResult->getSource();
 }
示例#5
0
文件: SearchManager.php 项目: ojs/ojs
 /**
  * @param  Result $authorObject
  * @return string
  */
 private function generateAuthorUrl(Result $authorObject)
 {
     $source = $authorObject->getSource();
     //check article count
     if (count($source['articleAuthors']) < 1) {
         return false;
     }
     //check article id is exists
     if (isset($source['articleAuthors'][0]['article']['id'])) {
         $article = $source['articleAuthors'][0]['article'];
     } else {
         return false;
     }
     //check article issue is exists
     if (isset($article['issue']['id'])) {
         $issue = $article['issue'];
     } else {
         return false;
     }
     //check article journal is exists
     if (isset($article['journal'])) {
         $journal = $article['journal'];
     } else {
         return false;
     }
     return $this->router->generate('ojs_article_page', ['slug' => $journal['slug'], 'article_id' => $article['id'], 'issue_id' => $issue['id']], true);
 }
示例#6
0
 /**
  * Wrapper around formatBean based on Result
  *
  * @param \RestService $api
  * @param Result       $result
  *
  * @return array
  */
 protected function formatBeanFromResult(\RestService $api, array $args, \Elastica\Result $result, SugarBean $bean)
 {
     // pass in field list from available data fields on result
     if (empty($args['fields'])) {
         $args['fields'] = array_keys($result->getSource());
     }
     $bean->retrieve($result->getId());
     return $this->formatBean($api, $args, $bean);
 }