Elastica\Result::getId PHP Method

getId() public method

Returns the hit id.
public getId ( ) : string
return string Hit id
    public function getId()
    {
        return $this->getParam('_id');
    }

Usage Example

 /**
  * 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();
     }
 }
All Usage Examples Of Elastica\Result::getId