Added examples

This commit is contained in:
delvedor
2019-02-14 16:25:16 +01:00
parent 9bbae42ccc
commit 1c2dbf6e76
6 changed files with 342 additions and 0 deletions

View File

@ -0,0 +1,32 @@
= Get
The get API allows to get a typed JSON document from the index based on its id. +
The following example gets a JSON document from an index called `game-of-thrones`, under a type called `_doc`, with id valued `'1'`.
[source,js]
---------
'use strict'
const { Client } = require('@elastic/elasticsearch')
const client = new Client({ node: 'http://localhost:9200' })
async function run () {
await client.index({
index: 'game-of-thrones',
id: '1',
body: {
character: 'Ned Stark',
quote: 'Winter is coming.'
}
})
const { body } = await client.get({
index: 'game-of-thrones',
id: '1'
})
console.log(body)
}
run().catch(console.log)
---------