Update connecting documentation (#1666)

This commit is contained in:
Tomas Della Vedova
2022-03-28 12:22:47 +02:00
committed by GitHub
parent 77c1ef36aa
commit eac00e1200
25 changed files with 315 additions and 100 deletions

View File

@ -9,7 +9,10 @@ data.
'use strict'
const { Client } = require('@elastic/elasticsearch')
const client = new Client({ node: 'http://localhost:9200' })
const client = new Client({
cloud: { id: '<cloud-id>' },
auth: { apiKey: 'base64EncodedKey' }
})
async function run () {
const bulkResponse = await client.bulk({
@ -83,7 +86,10 @@ send it directly to another source.
'use strict'
const { Client } = require('@elastic/elasticsearch')
const client = new Client({ node: 'http://localhost:9200' })
const client = new Client({
cloud: { id: '<cloud-id>' },
auth: { apiKey: 'base64EncodedKey' }
})
const fastify = require('fastify')()
fastify.post('/search/:index', async (req, reply) => {

View File

@ -13,7 +13,8 @@ NOTE: Did you know that we provide an helper for sending bulk request? You can f
require('array.prototype.flatmap').shim()
const { Client } = require('@elastic/elasticsearch')
const client = new Client({
node: 'http://localhost:9200'
cloud: { id: '<cloud-id>' },
auth: { apiKey: 'base64EncodedKey' }
})
async function run () {

View File

@ -10,7 +10,10 @@ NOTE: Since this API uses the `HEAD` method, the body value will be boolean.
'use strict'
const { Client } = require('@elastic/elasticsearch')
const client = new Client({ node: 'http://localhost:9200' })
const client = new Client({
cloud: { id: '<cloud-id>' },
auth: { apiKey: 'base64EncodedKey' }
})
async function run () {
await client.index({

View File

@ -10,7 +10,10 @@ The following example gets a JSON document from an index called
'use strict'
const { Client } = require('@elastic/elasticsearch')
const client = new Client({ node: 'http://localhost:9200' })
const client = new Client({
cloud: { id: '<cloud-id>' },
auth: { apiKey: 'base64EncodedKey' }
})
async function run () {
await client.index({

View File

@ -8,7 +8,10 @@ HTTP status codes which should not be considered errors for this request.
'use strict'
const { Client } = require('@elastic/elasticsearch')
const client = new Client({ node: 'http://localhost:9200' })
const client = new Client({
cloud: { id: '<cloud-id>' },
auth: { apiKey: 'base64EncodedKey' }
})
async function run () {
const bulkResponse = await client.bulk({

View File

@ -9,7 +9,10 @@ API.
'use strict'
const { Client } = require('@elastic/elasticsearch')
const client = new Client({ node: 'http://localhost:9200' })
const client = new Client({
cloud: { id: '<cloud-id>' },
auth: { apiKey: 'base64EncodedKey' }
})
async function run () {
const bulkResponse = await client.bulk({

View File

@ -15,7 +15,10 @@ the house Stark and remove the `house` field from the document source.
'use strict'
const { Client } = require('@elastic/elasticsearch')
const client = new Client({ node: 'http://localhost:9200' })
const client = new Client({
cloud: { id: '<cloud-id>' },
auth: { apiKey: 'base64EncodedKey' }
})
async function run () {
await client.index({

View File

@ -26,7 +26,10 @@ NOTE: Did you know that we provide an helper for sending scroll requests? You ca
'use strict'
const { Client } = require('@elastic/elasticsearch')
const client = new Client({ node: 'http://localhost:9200' })
const client = new Client({
cloud: { id: '<cloud-id>' },
auth: { apiKey: 'base64EncodedKey' }
})
async function run () {
const allQuotes = []
@ -118,7 +121,10 @@ async iteration!
'use strict'
const { Client } = require('@elastic/elasticsearch')
const client = new Client({ node: 'http://localhost:9200' })
const client = new Client({
cloud: { id: '<cloud-id>' },
auth: { apiKey: 'base64EncodedKey' }
})
// Scroll utility
async function * scrollSearch (params) {

View File

@ -12,7 +12,10 @@ https://www.elastic.co/guide/en/elasticsearch/reference/6.6/search-request-body.
'use strict'
const { Client } = require('@elastic/elasticsearch')
const client = new Client({ node: 'http://localhost:9200' })
const client = new Client({
cloud: { id: '<cloud-id>' },
auth: { apiKey: 'base64EncodedKey' }
})
async function run () {
// Let's start by indexing some data

View File

@ -17,7 +17,10 @@ manipulate the result to obtain an object easy to navigate.
'use strict'
const { Client } = require('@elastic/elasticsearch')
const client = new Client({ node: 'http://localhost:9200' })
const client = new Client({
cloud: { id: '<cloud-id>' },
auth: { apiKey: 'base64EncodedKey' }
})
async function run () {
await client.index({

View File

@ -12,7 +12,10 @@ request. If the query part is left out, only suggestions are returned.
'use strict'
const { Client } = require('@elastic/elasticsearch')
const client = new Client({ node: 'http://localhost:9200' })
const client = new Client({
cloud: { id: '<cloud-id>' },
auth: { apiKey: 'base64EncodedKey' }
})
async function run () {
const bulkResponse = await client.bulk({

View File

@ -20,7 +20,10 @@ maintain.
'use strict'
const { Client } = require('@elastic/elasticsearch')
const client = new Client({ node: 'http://localhost:9200' })
const client = new Client({
cloud: { id: '<cloud-id>' },
auth: { apiKey: 'base64EncodedKey' }
})
async function run () {
const bulkResponse = await client.bulk({

View File

@ -10,7 +10,10 @@ a character has said the given quote, and then we will update the `times` field.
'use strict'
const { Client } = require('@elastic/elasticsearch')
const client = new Client({ node: 'http://localhost:9200' })
const client = new Client({
cloud: { id: '<cloud-id>' },
auth: { apiKey: 'base64EncodedKey' }
})
async function run () {
await client.index({
@ -54,7 +57,10 @@ With the update API, you can also run a partial update of a document.
'use strict'
const { Client } = require('@elastic/elasticsearch')
const client = new Client({ node: 'http://localhost:9200' })
const client = new Client({
cloud: { id: '<cloud-id>' },
auth: { apiKey: 'base64EncodedKey' }
})
async function run () {
await client.index({

View File

@ -10,7 +10,10 @@ property or some other online mapping change.
'use strict'
const { Client } = require('@elastic/elasticsearch')
const client = new Client({ node: 'http://localhost:9200' })
const client = new Client({
cloud: { id: '<cloud-id>' },
auth: { apiKey: 'base64EncodedKey' }
})
async function run () {
await client.index({