[[reference-index]]

////////
===========================================================================================================================
||                                                                                                                       ||
||                                                                                                                       ||
||                                                                                                                       ||
||        ██████╗ ███████╗ █████╗ ██████╗ ███╗   ███╗███████╗                                                            ||
||        ██╔══██╗██╔════╝██╔══██╗██╔══██╗████╗ ████║██╔════╝                                                            ||
||        ██████╔╝█████╗  ███████║██║  ██║██╔████╔██║█████╗                                                              ||
||        ██╔══██╗██╔══╝  ██╔══██║██║  ██║██║╚██╔╝██║██╔══╝                                                              ||
||        ██║  ██║███████╗██║  ██║██████╔╝██║ ╚═╝ ██║███████╗                                                            ||
||        ╚═╝  ╚═╝╚══════╝╚═╝  ╚═╝╚═════╝ ╚═╝     ╚═╝╚══════╝                                                            ||
||                                                                                                                       ||
||                                                                                                                       ||
||    This file is autogenerated, DO NOT send pull requests that changes this file directly.                             ||
||    You should update the script that does the generation, which can be found in:                                      ||
||    https://github.com/elastic/elastic-client-generator-js                                                             ||
||                                                                                                                       ||
||    You can run the script with the following command:                                                                 ||
||       npm run elasticsearch -- --version <version>                                                                    ||
||                                                                                                                       ||
||                                                                                                                       ||
||                                                                                                                       ||
===========================================================================================================================
////////

[discrete]
[[client.index]]
=== client.index

Index a document. Adds a JSON document to the specified data stream or index and makes it searchable. If the target is an index and the document already exists, the request updates the document and increments its version.

{ref}/docs-index_.html[{es} documentation]

[discrete]
==== Function signature

[source,ts]
----
(IndexRequest, options?): Promise<IndexResponse>
----

[discrete]
==== IndexRequest

[pass]
++++
<pre>
++++
interface IndexRequest<TDocument = unknown> extends <<RequestBase>> {
  id?: <<Id>>
  index: <<IndexName>>
  if_primary_term?: <<long>>
  if_seq_no?: <<SequenceNumber>>
  op_type?: <<OpType>>
  pipeline?: string
  refresh?: <<Refresh>>
  routing?: <<Routing>>
  timeout?: <<Duration>>
  version?: <<VersionNumber>>
  version_type?: <<VersionType>>
  wait_for_active_shards?: <<WaitForActiveShards>>
  require_alias?: boolean
  document?: TDocument
}

[pass]
++++
</pre>
++++
[discrete]
==== IndexResponse

[pass]
++++
<pre>
++++
type IndexResponse = <<WriteResponseBase>>

[pass]
++++
</pre>
++++
