Method: Elasticsearch::API::Actions#exists
- Defined in:
- lib/elasticsearch/api/actions/exists.rb
#exists(arguments = {}) ⇒ Object Also known as: exists?
Returns information about whether a document exists in an index.
*Deprecation notice*: Specifying types in urls has been deprecated Deprecated since version 7.0.0
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/elasticsearch/api/actions/exists.rb', line 45 def exists(arguments = {}) raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] raise ArgumentError, "Required argument 'id' missing" unless arguments[:id] headers = arguments.delete(:headers) || {} arguments = arguments.clone _id = arguments.delete(:id) _index = arguments.delete(:index) _type = arguments.delete(:type) method = Elasticsearch::API::HTTP_HEAD path = if _index && _type && _id "#{Utils.__listify(_index)}/#{Utils.__listify(_type)}/#{Utils.__listify(_id)}" else "#{Utils.__listify(_index)}/_doc/#{Utils.__listify(_id)}" end params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) body = nil Utils.__rescue_from_not_found do perform_request(method, path, params, body, headers).status == 200 ? true : false end end |