Skip to content

Commit

Permalink
Index creation only accepts PUT verbs now
Browse files Browse the repository at this point in the history
  • Loading branch information
polyfractal committed Sep 15, 2016
1 parent 72f3b15 commit 9c620c2
Showing 1 changed file with 0 additions and 5 deletions.
5 changes: 0 additions & 5 deletions src/Elasticsearch/Endpoints/Indices/Create.php
Expand Up @@ -72,11 +72,6 @@ public function getParamWhitelist()
*/
public function getMethod()
{
if (is_array($this->body) && isset($this->body['mappings']) === true) {
return 'POST';
} elseif (is_object($this->body) && isset($this->body->mappings) === true) {
return 'POST';
}
return 'PUT';
}
}

2 comments on commit 9c620c2

@wangfei800
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit seems wrong, index creation will fail since this return a 'POST' for body with 'mappings'.

@polyfractal
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In 5.x, the Create Index API only accepts PUT, even if there is a mapping added: https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-create-index.html#mappings

If you need to add a mapping to an existing index, you can use the PutMapping api: https://github.com/elastic/elasticsearch-php/blob/master/src/Elasticsearch/Namespaces/IndicesNamespace.php#L598

Please sign in to comment.