IMPORTANT: elasticsearch.js has been replaced by the new Elasticsearch JavaScript client. We strongly advise you to migrate to the new client. To learn more, see the migration guide.
index
editindex
editclient.index([params, [callback]])
Stores a typed JSON document in an index, making it searchable. When the id
param is not set, a unique id will be auto-generated. When you specify an id
either a new document will be created, or an existing document will be updated. To enforce "put-if-absent" behavior set the opType
to "create"
or use the create()
method.
Optimistic concurrency control is performed, when the version
argument is specified. By default, no version checks are performed.
By default, the document will be available for get()
actions immediately, but will only be available for searching after an index refresh (which can happen automatically or manually). See indices.refresh
.
Check the API Conventions and the elasticsearch docs for more information pertaining to this method.
Create or update a document.
const response = await client.index({ index: 'myindex', type: 'mytype', id: '1', body: { title: 'Test 1', tags: ['y', 'z'], published: true, } });
Params
|
|
|
|
|
|
|
|
|
|
|
|
|
Timestamp — Explicit timestamp for the document |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|