Change ignore_missing to ignore
This commit is contained in:
@@ -166,7 +166,7 @@ class Elasticsearch(object):
|
||||
return True
|
||||
|
||||
@query_params('fields', 'parent', 'preference', 'realtime', 'refresh', 'routing')
|
||||
def get(self, index, id, doc_type='_all', ignore_missing=False, params=None):
|
||||
def get(self, index, id, doc_type='_all', ignore=(), params=None):
|
||||
"""
|
||||
Get a typed JSON document from the index based on its id.
|
||||
http://elasticsearch.org/guide/reference/api/get/
|
||||
@@ -175,7 +175,8 @@ class Elasticsearch(object):
|
||||
:arg id: The document ID
|
||||
:arg doc_type: The type of the document (uses `_all` by default to
|
||||
fetch the first document matching the ID across all types)
|
||||
:arg ignore_missing: if True will not raise an exception on 404
|
||||
:arg ignore: a list of http status number that should be ignored
|
||||
instead of raised as exceptions
|
||||
:arg fields: A comma-separated list of fields to return in the response
|
||||
:arg parent: The ID of the parent document
|
||||
:arg preference: Specify the node or shard the operation should be
|
||||
@@ -189,14 +190,14 @@ class Elasticsearch(object):
|
||||
try:
|
||||
_, data = self.transport.perform_request('GET', _make_path(index, doc_type, id),
|
||||
params=params)
|
||||
except NotFoundError:
|
||||
if ignore_missing:
|
||||
except TransportError as e:
|
||||
if e.status_code == ignore:
|
||||
return
|
||||
raise
|
||||
return data
|
||||
|
||||
@query_params('parent', 'preference', 'realtime', 'refresh', 'routing')
|
||||
def get_source(self, index, id, doc_type='_all', ignore_missing=False, params=None):
|
||||
def get_source(self, index, id, doc_type='_all', ignore=(), params=None):
|
||||
"""
|
||||
Get the source of a document by it's index, type and id.
|
||||
http://elasticsearch.org/guide/reference/api/get/
|
||||
@@ -205,7 +206,8 @@ class Elasticsearch(object):
|
||||
:arg doc_type: The type of the document (uses `_all` by default to
|
||||
fetch the first document matching the ID across all types)
|
||||
:arg id: The document ID
|
||||
:arg ignore_missing: if True will not raise an exception on 404 and just return `None`
|
||||
:arg ignore: a list of http status number that should be ignored
|
||||
instead of raised as exceptions
|
||||
:arg parent: The ID of the parent document
|
||||
:arg preference: Specify the node or shard the operation should be
|
||||
performed on (default: random)
|
||||
@@ -217,8 +219,8 @@ class Elasticsearch(object):
|
||||
try:
|
||||
_, data = self.transport.perform_request('GET', _make_path(index, doc_type, id, '_source'),
|
||||
params=params)
|
||||
except NotFoundError:
|
||||
if ignore_missing:
|
||||
except TransportError as e:
|
||||
if e.status_code == ignore:
|
||||
return
|
||||
raise
|
||||
return data
|
||||
@@ -249,7 +251,7 @@ class Elasticsearch(object):
|
||||
@query_params('consistency', 'fields', 'lang', 'parent', 'percolate',
|
||||
'refresh', 'replication', 'retry_on_conflict', 'routing', 'script',
|
||||
'timeout', 'timestamp', 'ttl', 'version', 'version_type')
|
||||
def update(self, index, doc_type, id, body=None, ignore_missing=False, params=None):
|
||||
def update(self, index, doc_type, id, body=None, ignore=(), params=None):
|
||||
"""
|
||||
Update a document based on a script or partial data provided.
|
||||
http://elasticsearch.org/guide/reference/api/update/
|
||||
@@ -258,8 +260,8 @@ class Elasticsearch(object):
|
||||
:arg doc_type: The type of the document
|
||||
:arg id: Document ID
|
||||
:arg body: The request definition using either `script` or partial `doc`
|
||||
:arg ignore_missing: if True will not raise an exception on 404 and
|
||||
just return `None`
|
||||
:arg ignore: a list of http status number that should be ignored
|
||||
instead of raised as exceptions
|
||||
:arg consistency: Explicit write consistency setting for the operation
|
||||
:arg fields: A comma-separated list of fields to return in the response
|
||||
:arg lang: The script language (default: mvel)
|
||||
@@ -281,8 +283,8 @@ class Elasticsearch(object):
|
||||
try:
|
||||
_, data = self.transport.perform_request('POST', _make_path(index, doc_type, id, '_update'),
|
||||
params=params, body=body)
|
||||
except NotFoundError:
|
||||
if ignore_missing:
|
||||
except TransportError as e:
|
||||
if e.status_code == ignore:
|
||||
return
|
||||
raise
|
||||
return data
|
||||
@@ -361,7 +363,7 @@ class Elasticsearch(object):
|
||||
|
||||
@query_params('consistency', 'parent', 'refresh', 'replication', 'routing',
|
||||
'timeout', 'version', 'version_type')
|
||||
def delete(self, index, doc_type, id, ignore_missing=False, params=None):
|
||||
def delete(self, index, doc_type, id, ignore=(), params=None):
|
||||
"""
|
||||
Delete a typed JSON document from a specific index based on its id.
|
||||
http://elasticsearch.org/guide/reference/api/delete/
|
||||
@@ -369,7 +371,8 @@ class Elasticsearch(object):
|
||||
:arg index: The name of the index
|
||||
:arg doc_type: The type of the document
|
||||
:arg id: The document ID
|
||||
:arg ignore_missing: if True will not raise an exception on 404
|
||||
:arg ignore: a list of http status number that should be ignored
|
||||
instead of raised as exceptions
|
||||
:arg consistency: Specific write consistency setting for the operation
|
||||
:arg parent: ID of parent document
|
||||
:arg refresh: Refresh the index after performing the operation
|
||||
@@ -381,8 +384,8 @@ class Elasticsearch(object):
|
||||
"""
|
||||
try:
|
||||
_, data = self.transport.perform_request('DELETE', _make_path(index, doc_type, id), params=params)
|
||||
except NotFoundError:
|
||||
if ignore_missing:
|
||||
except TransportError as e:
|
||||
if e.status_code == ignore:
|
||||
return
|
||||
raise
|
||||
return data
|
||||
|
||||
Reference in New Issue
Block a user