Skip to content

Commit

Permalink
Merge pull request #951 from gbourgeat/master
Browse files Browse the repository at this point in the history
Add Field Data Fields property and possibility to get 'script_fields' in same time that '_source' fields in result
  • Loading branch information
ruflin committed Oct 8, 2015
2 parents 0462a83 + 0cc0a11 commit 7d1ac65
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
14 changes: 14 additions & 0 deletions lib/Elastica/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,20 @@ public function setFields(array $fields)
return $this->setParam('fields', $fields);
}

/**
* Sets the fields not stored to be returned by the search
*
* @param array $fieldDataFields Fields not stored to be returned
*
* @return $this
*
* @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-fielddata-fields.html
*/
public function setFieldDataFields(array $fieldDataFields)
{
return $this->setParam('fielddata_fields', $fieldDataFields);
}

/**
* Set script fields.
*
Expand Down
4 changes: 3 additions & 1 deletion lib/Elastica/Result.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,14 +142,16 @@ public function getVersion()
/**
* Returns result data.
*
* Checks for partial result data with getFields, falls back to getSource
* Checks for partial result data with getFields, falls back to getSource or both
*
* @return array Result data array
*/
public function getData()
{
if (isset($this->_hit['fields']) && !isset($this->_hit['_source'])) {
return $this->getFields();
} else if (isset($this->_hit['fields']) && isset($this->_hit['_source'])) {
return array_merge($this->getFields(), $this->getSource());
}

return $this->getSource();
Expand Down

0 comments on commit 7d1ac65

Please sign in to comment.