Skip to content

Commit

Permalink
Resolve deprecation warning in Type::exists() (#1263)
Browse files Browse the repository at this point in the history
Elasticsearch 5 logs a deprecation warning when using the exists method:

[org.elasticsearch.deprecation.rest.action.admin.indices.RestTypesExistsAction]
[HEAD /{index}/{type}] is deprecated! Use [HEAD /{index}/_mapping/{type}] instead

Adjust the call to use the appropriate REST url.
  • Loading branch information
ebernhardson authored and ruflin committed Mar 6, 2017
1 parent 81b48a6 commit f329210
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ All notable changes to this project will be documented in this file based on the
- `\Elastica\Query\MatchPhrase` and `\Elastica\Query\MatchPhrasePrefix` do not extend `\Elastica\Query\Match` anymore because they do not share exactly the same options
- Removed the `routing` option in `\Elastica\Index::create` because there is no routing param when creating an index. So that option was doing nothing so far but fails in Elasticearch 5.0 because the non-existing query param is validated.
- Fix `relation` property of `\Elastica\Query\GeoShapeProvided`
- repoint `\Elastica\Type::exists` from the deprecated /{index}/{type} endpoint to /{index}/_mapping/{type}

### Added

Expand Down
3 changes: 2 additions & 1 deletion lib/Elastica/Type.php
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,8 @@ public function setSerializer($serializer)
*/
public function exists()
{
$response = $this->getIndex()->request($this->getName(), Request::HEAD);
$path = '_mapping/' . $this->getName();
$response = $this->getIndex()->request($path, Request::HEAD);

return $response->getStatus() === 200;
}
Expand Down

0 comments on commit f329210

Please sign in to comment.