Skip to main content


Elasticsearch is the world's leading free and open search and analytics solution.

Official Website
Network Connection needs

This integration needs network access to the server where the service is running.

See the Network access page for details about how to achieve that.

Credential configuration

Fill in the appropiate values for your connection, depending on whether you are using or your own installation.

In the extra options field, you can provide any of the parameters found here.

Here is an example of a filled credential configuration form in YepCode:

Elasticsearch snippets available in editor


The title is the triggering text for YepCode to autocomplete the script.


New integration from credential
const elasticsearch = yepcode.integration.elasticsearch('credential-slug')
New integration from plain authentication data
const { Client } = require('@elastic/elasticsearch')

const elasticsearch = new Client({
cloud: { id: '<cloud-id>' },
auth: { apiKey: 'base64EncodedKey' }

Add Data to an Index

Add data to an index
cosnt document = {
character: 'Ned Stark',
quote: 'Winter is coming.'

await elasticsearch.index({
index: 'game-of-thrones',
body: document

Execute Query

Execute query
  const result = await elasticsearch.sql.query({
query: "SELECT * FROM \"game-of-thrones\" WHERE house='stark'"


const data = => {
const obj = {}
for (let i = 0; i < row.length; i++) {
obj[result.columns[i].name] = row[i]
return obj

Execute get
  const document = await elasticsearch.get({
index: 'game-of-thrones',
id: '1'

Execute query (stream)
  const result = await{
index: 'game-of-thrones',
query: {
match: {
quote: 'winter'
}, {
asStream: true

// stream async iteration, available in Node.js ≥ 10
let payload = ''
for await (const chunk of result) {
payload += chunk