Skip to content

Commit

Permalink
Make id param optionnal for termvectors requests. (#542)
Browse files Browse the repository at this point in the history
  • Loading branch information
afoucret authored and polyfractal committed Mar 2, 2017
1 parent ccfb5a6 commit e6f79de
Showing 1 changed file with 23 additions and 19 deletions.
42 changes: 23 additions & 19 deletions src/Elasticsearch/Endpoints/TermVectors.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,27 +39,31 @@ public function setBody($body)
public function getURI()
{
if (isset($this->index) !== true) {
throw new Exceptions\RuntimeException(
'index is required for TermVectors'
);
}
if (isset($this->type) !== true) {
throw new Exceptions\RuntimeException(
'type is required for TermVectors'
);
}
if (isset($this->id) !== true) {
throw new Exceptions\RuntimeException(
'id is required for TermVectors'
);
}
throw new Exceptions\RuntimeException(
'index is required for TermVectors'
);
}
if (isset($this->type) !== true) {
throw new Exceptions\RuntimeException(
'type is required for TermVectors'
);
}
if (isset($this->id) !== true && isset($this->body['doc']) !== true) {
throw new Exceptions\RuntimeException(
'id or doc is required for TermVectors'
);
}

$index = $this->index;
$type = $this->type;
$id = $this->id;
$uri = "/$index/$type/_termvectors";

$index = $this->index;
$type = $this->type;
$id = $this->id;
$uri = "/$index/$type/$id/_termvectors";
if ($id !== null) {
$uri = "/$index/$type/$id/_termvectors";
}

return $uri;
return $uri;
}

/**
Expand Down

0 comments on commit e6f79de

Please sign in to comment.