getId() public method

Returns the hit id.
public getId ( ) : string
return string Hit id
コード例 #1
0
 /**
  * Takes either an array or a Result object form a search and constructs
  * a document representing an entity in a elastic search type,
  *
  * @param array|Elastica\Result $data An array or Result object that
  *  represents an Elasticsearch document
  * @param array $options An array of options to set the state of the
  *  document
  */
 public function __construct($data = [], $options = [])
 {
     if ($data instanceof Result) {
         $options['result'] = $data;
         $id = $data->getId();
         $data = $data->getData();
         if ($id !== []) {
             $data['id'] = $id;
         }
     }
     $options += ['useSetters' => true, 'markClean' => false, 'markNew' => null, 'guard' => false, 'source' => null, 'result' => null];
     if (!empty($options['source'])) {
         $this->source($options['source']);
     }
     if ($options['markNew'] !== null) {
         $this->isNew($options['markNew']);
     }
     if ($options['result'] !== null) {
         $this->_result = $options['result'];
     }
     if (!empty($data) && $options['markClean'] && !$options['useSetters']) {
         $this->_properties = $data;
         return;
     }
     if (!empty($data)) {
         $this->set($data, ['setter' => $options['useSetters'], 'guard' => $options['guard']]);
     }
     if ($options['markClean']) {
         $this->clean();
     }
 }
コード例 #2
0
ファイル: LocationTransformer.php プロジェクト: phpfour/ah
 /**
  * {@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;
 }
コード例 #3
0
 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;
 }
コード例 #4
0
ファイル: SearchManager.php プロジェクト: hasantayyar/ojs
 /**
  * @param  Result $articleObject
  * @return string
  */
 private function generateArticleUrl(Result $articleObject)
 {
     $source = $articleObject->getSource();
     if (!isset($source['issue']['id'])) {
         return false;
     }
     return $this->router->generate('ojs_article_page', ['slug' => $source['journal']['slug'], 'article_id' => $articleObject->getId(), 'issue_id' => $source['issue']['id'], 'publisher' => $source['journal']['publisher']['slug']], true);
 }
コード例 #5
0
 /**
  * Return the id of the
  *
  * @return string
  */
 public function getId()
 {
     return $this->elasticaResult->getId();
 }
コード例 #6
0
ファイル: GeoApi.php プロジェクト: matruszkowski/uncon
 /**
  * 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);
 }
コード例 #7
0
ファイル: JobTransformer.php プロジェクト: phpfour/ah
 /**
  * {@inheritDoc}
  */
 public function toModel(Result $result, Model $model)
 {
     $model = $model->find($result->getId());
     return $model;
 }