From 7011e9c4ad843126e470e8bfd7efc520d41d2849 Mon Sep 17 00:00:00 2001 From: Dan Date: Thu, 2 Apr 2020 00:20:13 +0100 Subject: [PATCH 1/2] feat: add _parent to document --- src/QueryProcessor.php | 4 ++++ 1 file changed, 4 insertions(+) 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']); } From 987158a90237be5d6a7747e04c979946bcb3e42c Mon Sep 17 00:00:00 2001 From: Dan Date: Thu, 2 Apr 2020 00:35:14 +0100 Subject: [PATCH 2/2] fix: unset _parent before saving --- src/Searchable.php | 1 + 1 file changed, 1 insertion(+) 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 ?? [];