existsedit

client.exists([params, [callback]])

Returns a boolean indicating whether or not a given document exists.

Check the API Conventions and the elasticsearch docs for more information pertaining to this method.

Check that the document /myindex/mytype/1 exist.

const exists = await client.exists({
  index: 'myindex',
  type: 'mytype',
  id: 1
});

Params

storedFields

String, String[], Boolean — A comma-separated list of stored fields to return in the response

preference

String — Specify the node or shard the operation should be performed on (default: random)

realtime

Boolean — Specify whether to perform the operation in realtime or search mode

refresh

Boolean — Refresh the shard containing the document before performing the operation

routing

String — Specific routing value

_source

String, String[], Boolean — True or false to return the _source field or not, or a list of fields to return

_sourceExcludes

String, String[], Boolean — A list of fields to exclude from the returned _source field

_sourceIncludes

String, String[], Boolean — A list of fields to extract and return from the _source field

version

Number — Explicit version number for concurrency control

versionType

String — Specific version type

Options
  • "internal"
  • "external"
  • "external_gte"
  • "force"

id

String — The document ID

index

String — The name of the index

type

String — The type of the document (use _all to fetch the first document matching the ID across all types)

body

Object, JSON — An optional request body, as either JSON or a JSON serializable object. See the elasticsearch docs for details about what can be specified here.

back to top