Skip to content
Snippets Groups Projects
Commit 8d6710fd authored by tchiotludo's avatar tchiotludo Committed by Simonas Šerlinskas
Browse files

InnerHit query is optional

parent 24d7f015
No related branches found
No related tags found
No related merge requests found
......@@ -48,7 +48,7 @@ class NestedInnerHit implements BuilderInterface
* @param string $path
* @param BuilderInterface $query
*/
public function __construct($name, $path, BuilderInterface $query)
public function __construct($name, $path, BuilderInterface $query = null)
{
$this->setName($name);
$this->setPath($path);
......@@ -82,7 +82,7 @@ class NestedInnerHit implements BuilderInterface
/**
* @param BuilderInterface $query
*/
public function setQuery(BuilderInterface $query)
public function setQuery(BuilderInterface $query = null)
{
$this->query = $query;
}
......@@ -145,14 +145,16 @@ class NestedInnerHit implements BuilderInterface
{
$out = array_filter(
[
'query' => $this->getQuery()->toArray(),
'query' => $this->getQuery() ? $this->getQuery()->toArray() : null,
'inner_hits' => $this->collectNestedInnerHits(),
]
);
$out = $this->processArray($out);
$out = [
$this->getPathType() => [
$this->getPath() => $this->processArray($out),
$this->getPath() => $out ? $out : new \stdClass(),
],
];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment