ignore_missing for get_source
This commit is contained in:
@@ -171,7 +171,7 @@ class Elasticsearch(object):
|
|||||||
return data
|
return data
|
||||||
|
|
||||||
@query_params('parent', 'preference', 'realtime', 'refresh', 'routing')
|
@query_params('parent', 'preference', 'realtime', 'refresh', 'routing')
|
||||||
def get_source(self, index, doc_type, id, params=None):
|
def get_source(self, index, doc_type, id, ignore_missing=False, params=None):
|
||||||
"""
|
"""
|
||||||
The get API allows to get the document source from the index based on its id.
|
The get API allows to get the document source from the index based on its id.
|
||||||
http://elasticsearch.org/guide/reference/api/get/
|
http://elasticsearch.org/guide/reference/api/get/
|
||||||
@@ -179,13 +179,19 @@ 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; use `_all` to fetch the first document matching the ID across all types
|
:arg doc_type: The type of the document; use `_all` to 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
|
||||||
: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 performed on (default: random)
|
:arg preference: Specify the node or shard the operation should be performed on (default: random)
|
||||||
:arg realtime: Specify whether to perform the operation in realtime or search mode
|
:arg realtime: Specify whether to perform the operation in realtime or search mode
|
||||||
:arg refresh: Refresh the shard containing the document before performing the operation
|
:arg refresh: Refresh the shard containing the document before performing the operation
|
||||||
:arg routing: Specific routing value
|
:arg routing: Specific routing value
|
||||||
"""
|
"""
|
||||||
status, data = self.transport.perform_request('GET', _make_path(index, doc_type, id, '_source'), params=params)
|
try:
|
||||||
|
status, data = self.transport.perform_request('GET', _make_path(index, doc_type, id, '_source'), params=params)
|
||||||
|
except NotFoundError:
|
||||||
|
if ignore_missing:
|
||||||
|
return
|
||||||
|
raise
|
||||||
return data
|
return data
|
||||||
|
|
||||||
@query_params('fields', 'parent', 'preference', 'realtime', 'refresh', 'routing')
|
@query_params('fields', 'parent', 'preference', 'realtime', 'refresh', 'routing')
|
||||||
@@ -217,6 +223,7 @@ 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
|
||||||
: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)
|
||||||
|
|||||||
Reference in New Issue
Block a user