diff --git a/src/QueryProcessor.php b/src/QueryProcessor.php index adcee66..6c25308 100644 --- a/src/QueryProcessor.php +++ b/src/QueryProcessor.php @@ -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']); } diff --git a/src/Searchable.php b/src/Searchable.php index 7ea4ead..0839dfa 100644 --- a/src/Searchable.php +++ b/src/Searchable.php @@ -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 ?? [];