innerHits = true; return $this; } public function toArray(): array { $hasChild = [ 'type' => $this->type, 'score_mode' => $this->scoreMode, 'query' => $this->query->toArray(), ]; if ($this->innerHits) { $hasChild['inner_hits'] = ['name' => 'best_post', 'size' => 1]; } return ['has_child' => $hasChild]; } }