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