Skip to content

Commit

Permalink
Merge pull request #101 from designmynight/parent-document
Browse files Browse the repository at this point in the history
feat: add _parent to document
  • Loading branch information
danjohnson95 authored Apr 2, 2020
2 parents 66b8aff + 987158a commit 0436525
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/QueryProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ public function documentFromResult(Builder $query, array $result): array
$document = $result['_source'];
$document['_id'] = $result['_id'];

if (! empty($result['_parent'])) {
$document['_parent'] = $result['_parent'];
}

if ($query->includeInnerHits && isset($result['inner_hits'])) {
$document = $this->addInnerHitsToDocument($document, $result['inner_hits']);
}
Expand Down
1 change: 1 addition & 0 deletions src/Searchable.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ public function toSearchableArray()
$array['id'] = $this->id;

unset($array['_id']);
unset($array['_parent']);

foreach ((array) $this->indexAsChildDocuments as $field) {
$subDocuments = $this->$field ?? [];
Expand Down

0 comments on commit 0436525

Please sign in to comment.