Skip to content

Commit

Permalink
If type is specified but not index, default to _all
Browse files Browse the repository at this point in the history
These endpoints should use the `_all` special index if a type is
specified but no index.
  • Loading branch information
polyfractal committed Jan 24, 2014
1 parent c053208 commit 60e653c
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
2 changes: 2 additions & 0 deletions src/Elasticsearch/Endpoints/Count.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ protected function getURI()

if (isset($index) === true && isset($type) === true) {
$uri = "/$index/$type/_count";
} elseif (isset($type) === true) {
$uri = "/_all/$type/_count";
} elseif (isset($index) === true) {
$uri = "/$index/_count";
}
Expand Down
2 changes: 2 additions & 0 deletions src/Elasticsearch/Endpoints/Mget.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ protected function getURI()
$uri = "/$index/$type/_mget";
} elseif (isset($index) === true) {
$uri = "/$index/_mget";
} elseif (isset($type) === true) {
$uri = "/_all/$type/_mget";
}

return $uri;
Expand Down
2 changes: 2 additions & 0 deletions src/Elasticsearch/Endpoints/Msearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ protected function getURI()
$uri = "/$index/$type/_msearch";
} elseif (isset($index) === true) {
$uri = "/$index/_msearch";
} elseif (isset($type) === true) {
$uri = "/_all/$type/_msearch";
}

return $uri;
Expand Down
11 changes: 3 additions & 8 deletions src/Elasticsearch/Endpoints/Search.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,7 @@ public function setBody($body)
return $this;
}

if (is_string($body) === true || is_array($body) === true) {
$this->body = $body;
} else {
throw new InvalidArgumentException(
'Query must be a string or array'
);
}

$this->body = $body;
return $this;
}

Expand All @@ -61,6 +54,8 @@ protected function getURI()
$uri = "/$index/$type/_search";
} elseif (isset($index) === true) {
$uri = "/$index/_search";
} elseif (isset($type) === true) {
$uri = "/_all/$type/_search";
}

return $uri;
Expand Down

0 comments on commit 60e653c

Please sign in to comment.