Skip to content

Commit e6f79de

Browse files
afoucretpolyfractal
authored andcommitted
Make id param optionnal for termvectors requests. (#542)
1 parent ccfb5a6 commit e6f79de

File tree

1 file changed

+23
-19
lines changed

1 file changed

+23
-19
lines changed

src/Elasticsearch/Endpoints/TermVectors.php

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -39,27 +39,31 @@ public function setBody($body)
3939
public function getURI()
4040
{
4141
if (isset($this->index) !== true) {
42-
throw new Exceptions\RuntimeException(
43-
'index is required for TermVectors'
44-
);
45-
}
46-
if (isset($this->type) !== true) {
47-
throw new Exceptions\RuntimeException(
48-
'type is required for TermVectors'
49-
);
50-
}
51-
if (isset($this->id) !== true) {
52-
throw new Exceptions\RuntimeException(
53-
'id is required for TermVectors'
54-
);
55-
}
42+
throw new Exceptions\RuntimeException(
43+
'index is required for TermVectors'
44+
);
45+
}
46+
if (isset($this->type) !== true) {
47+
throw new Exceptions\RuntimeException(
48+
'type is required for TermVectors'
49+
);
50+
}
51+
if (isset($this->id) !== true && isset($this->body['doc']) !== true) {
52+
throw new Exceptions\RuntimeException(
53+
'id or doc is required for TermVectors'
54+
);
55+
}
56+
57+
$index = $this->index;
58+
$type = $this->type;
59+
$id = $this->id;
60+
$uri = "/$index/$type/_termvectors";
5661

57-
$index = $this->index;
58-
$type = $this->type;
59-
$id = $this->id;
60-
$uri = "/$index/$type/$id/_termvectors";
62+
if ($id !== null) {
63+
$uri = "/$index/$type/$id/_termvectors";
64+
}
6165

62-
return $uri;
66+
return $uri;
6367
}
6468

6569
/**

0 commit comments

Comments
 (0)