Skip to content

Commit c057d70

Browse files
afoucretpolyfractal
authored andcommitted
Backport elastic#542 (Make id param optionnal for termvectors requests when doc is set in the body). (elastic#683)
1 parent cb3b243 commit c057d70

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/Elasticsearch/Endpoints/TermVectors.php

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,21 @@ protected function getURI()
6363
'type is required for TermVector'
6464
);
6565
}
66-
if (isset($this->id) !== true) {
67-
throw new Exceptions\RuntimeException(
68-
'id is required for TermVector'
69-
);
66+
if (isset($this->id) !== true && isset($this->body['doc']) !== true) {
67+
throw new Exceptions\RuntimeException(
68+
'id or doc is required for TermVectors'
69+
);
7070
}
71+
7172
$index = $this->index;
7273
$type = $this->type;
7374
$id = $this->id;
74-
$uri = "/$index/$type/$id/_termvector" . ($this->shouldUseDeprecated ? '' : 's');
75+
76+
$uri = "/$index/$type/_termvector" . ($this->shouldUseDeprecated ? '' : 's');
77+
78+
if ($id !== null) {
79+
$uri = "/$index/$type/$id/_termvector" . ($this->shouldUseDeprecated ? '' : 's');
80+
}
7581

7682
return $uri;
7783
}

0 commit comments

Comments
 (0)