indices.exists_type
This commit is contained in:
@@ -175,6 +175,22 @@ class InidicesClient(NamespacedClient):
|
|||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@query_params('ignore_indices')
|
||||||
|
def exists_type(self, index, doc_type, params=None):
|
||||||
|
"""
|
||||||
|
Used to check if a type/types exists in an index/indices (available since 0.
|
||||||
|
http://www.elasticsearch.org/guide/reference/api/admin-indices-types-exists/
|
||||||
|
|
||||||
|
:arg index: A comma-separated list of index names; use `_all` to check the types across all indices
|
||||||
|
:arg doc_type: A comma-separated list of document types to check
|
||||||
|
:arg ignore_indices: When performed on multiple indices, allows to ignore `missing` ones, default u'none'
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
self.transport.perform_request('HEAD', _make_path(index, doc_type), params=params)
|
||||||
|
except NotFoundError:
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
@query_params('ignore_conflicts', 'timeout')
|
@query_params('ignore_conflicts', 'timeout')
|
||||||
def put_mapping(self, index, body, doc_type=None, params=None):
|
def put_mapping(self, index, body, doc_type=None, params=None):
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -59,6 +59,9 @@ class YamlTestCase(TestCase):
|
|||||||
|
|
||||||
def run_is(self, action, transform=None):
|
def run_is(self, action, transform=None):
|
||||||
""" Match part of last response to test data. """
|
""" Match part of last response to test data. """
|
||||||
|
|
||||||
|
# matching part of the reponse dict
|
||||||
|
if isinstance(action, dict):
|
||||||
self.assertEquals(1, len(action))
|
self.assertEquals(1, len(action))
|
||||||
path, expected = list(action.items())[0]
|
path, expected = list(action.items())[0]
|
||||||
|
|
||||||
@@ -73,6 +76,11 @@ class YamlTestCase(TestCase):
|
|||||||
self.assertIn(step, value)
|
self.assertIn(step, value)
|
||||||
value = value[step]
|
value = value[step]
|
||||||
|
|
||||||
|
# matching the entire response
|
||||||
|
else:
|
||||||
|
value = self.last_response
|
||||||
|
expected = action
|
||||||
|
|
||||||
# sometimes we need to transform the json value before comparing
|
# sometimes we need to transform the json value before comparing
|
||||||
if transform:
|
if transform:
|
||||||
value = transform(value)
|
value = transform(value)
|
||||||
|
|||||||
@@ -29,3 +29,17 @@
|
|||||||
indices.get_mapping:
|
indices.get_mapping:
|
||||||
index: test
|
index: test
|
||||||
- length: { test: 0 }
|
- length: { test: 0 }
|
||||||
|
---
|
||||||
|
"Test type exists":
|
||||||
|
- do:
|
||||||
|
indices.exists_type:
|
||||||
|
index: test
|
||||||
|
type: test-type
|
||||||
|
- is: true
|
||||||
|
---
|
||||||
|
"Test type doesn't exists":
|
||||||
|
- do:
|
||||||
|
indices.exists_type:
|
||||||
|
index: test
|
||||||
|
type: not-test-type
|
||||||
|
- is: false
|
||||||
|
|||||||
Reference in New Issue
Block a user