Compare commits
228 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f4f9264707 | |||
| 553c41936c | |||
| 95cd9b1378 | |||
| 152027df28 | |||
| 60af770748 | |||
| f1430fc883 | |||
| 5be4ae40b8 | |||
| e564cb6c80 | |||
| 7b4c799fd8 | |||
| 7feb422c77 | |||
| af0188d1d4 | |||
| f17bfaddf6 | |||
| 08777446c1 | |||
| 71fe13f7cb | |||
| dd33c6fc0f | |||
| 8bf11b6e17 | |||
| 73ef18836e | |||
| c988c44f66 | |||
| 60e745dbb4 | |||
| 3b6c2e1be6 | |||
| 1fec78ed36 | |||
| a3989d538c | |||
| 41cb67e9df | |||
| 652fd8cec9 | |||
| 844f4e6b0d | |||
| 4d60acb5cd | |||
| 1337d4332f | |||
| d5552dca2a | |||
| 8ca68a4178 | |||
| 3e5e568c07 | |||
| ac231c859e | |||
| a22c4622d9 | |||
| 6f9e1062f3 | |||
| 7449adbd1f | |||
| d5a0f1171f | |||
| d86eb82e82 | |||
| a411cc7c7d | |||
| c99abab058 | |||
| c5b2915b5a | |||
| 20fb610d82 | |||
| c8504fe616 | |||
| 4795a8c0d5 | |||
| 9139662bcc | |||
| 9e4572f4e1 | |||
| a25bc97297 | |||
| 172180cb21 | |||
| 947e09e62a | |||
| 86169003b4 | |||
| 11ff146ae8 | |||
| d2c63b4c5f | |||
| 0ad42ff1a2 | |||
| 6dbf91a9c3 | |||
| 39b2700add | |||
| 869174f953 | |||
| 5eb3554083 | |||
| 26ce906b5b | |||
| 5f9561d566 | |||
| 3676c8229a | |||
| 2bcbd36d75 | |||
| 63104b5e5e | |||
| 2b2a9947c7 | |||
| b95aa986b7 | |||
| 0ee486bc9c | |||
| f835fa3b12 | |||
| e688f36396 | |||
| b8c3ac446e | |||
| 3a288cf86b | |||
| 100be27ad1 | |||
| c490dd0821 | |||
| e992c329c3 | |||
| bfdae66333 | |||
| ed3cace127 | |||
| f33aa8cccd | |||
| 7cb973a206 | |||
| a4315a905e | |||
| 6447fc10bf | |||
| e9c2f8b0af | |||
| 15b9ee2f06 | |||
| e30e964131 | |||
| 0f187f47c4 | |||
| 101f34bd5e | |||
| ec0c561e36 | |||
| c1e90b12f0 | |||
| 5cb670256e | |||
| 86f488f68f | |||
| 6009fab7fe | |||
| 26ae260058 | |||
| fbbbece711 | |||
| a30c3dca2d | |||
| 36cfacc409 | |||
| 6dc83cd33e | |||
| 7c7ce29127 | |||
| 2b890af355 | |||
| 421f953b00 | |||
| c5e4107181 | |||
| 5880c84c13 | |||
| 290639d168 | |||
| 0b90613694 | |||
| 1ad057abcc | |||
| 44d890ec57 | |||
| 2b2a2f03e6 | |||
| 7bcd75bdb0 | |||
| 2455dac4e5 | |||
| edb5563bf8 | |||
| 11939fd22c | |||
| e0c613f898 | |||
| 20f2c740cd | |||
| 97bdca22d8 | |||
| a7123f807d | |||
| 20ac2a637e | |||
| e287c1edd9 | |||
| 90d43f4f28 | |||
| 572927b4f1 | |||
| 86b4d4e2f9 | |||
| 8e79bf847a | |||
| cef328c93d | |||
| c3247d0c66 | |||
| e9fdcb0647 | |||
| 82acfc33a9 | |||
| 661caf8422 | |||
| 3430734fe0 | |||
| 810e009202 | |||
| c274b1b32f | |||
| 428a7b023d | |||
| aad41df231 | |||
| 34704b2e5c | |||
| 58b457eedc | |||
| 132d6d6062 | |||
| 9e08aaebe2 | |||
| 889fee2316 | |||
| 83b32f7ef4 | |||
| 60aa521b7e | |||
| 608b517d64 | |||
| bf4c57f7bc | |||
| 715292b501 | |||
| 1042a02733 | |||
| 9c959971a5 | |||
| e2745b4c75 | |||
| 4b8969cc78 | |||
| d62d8c9831 | |||
| 77e2f613f2 | |||
| 69b243171b | |||
| 37b8a33209 | |||
| 99cefe8b19 | |||
| 84ab2a787d | |||
| f737290d10 | |||
| 94da0d241a | |||
| 384debee9e | |||
| 94bf5b2aa7 | |||
| f34bb6aa28 | |||
| 1f9db892ea | |||
| 069103612a | |||
| db911746a0 | |||
| 7b255bed98 | |||
| 74be52ebb1 | |||
| 0e5beddd65 | |||
| bd89ab5dd7 | |||
| c202a6bbc5 | |||
| 8e162dd8b8 | |||
| 2b0eebc8fa | |||
| f97ba5b02a | |||
| 72a1114186 | |||
| 542585a5dc | |||
| e1de2bd53d | |||
| 4be14a1f6c | |||
| a71ebb5f68 | |||
| 05f7078534 | |||
| b250049ee7 | |||
| fe2d8c1915 | |||
| b9ea8f8906 | |||
| 896216860f | |||
| 45e3c0657a | |||
| b65e468b95 | |||
| 768ba3d8ae | |||
| 2da30cd4cd | |||
| a13992ec7d | |||
| 95fd81a883 | |||
| 6f2aaa5c7c | |||
| b857d8ee71 | |||
| 4aa00e03e1 | |||
| e2974b0747 | |||
| 3bd7ba95f8 | |||
| f96aa32345 | |||
| 628254df2d | |||
| 1ef318aded | |||
| ec9a4dc960 | |||
| f3d9dfb48e | |||
| 7f7942e207 | |||
| d584836399 | |||
| c7cbe941db | |||
| 113b32258d | |||
| 6e63530801 | |||
| 38c17fd7f3 | |||
| 63eb92b42a | |||
| 7475dba8b9 | |||
| 3ad00b4a9f | |||
| 2721008867 | |||
| c106146d30 | |||
| 78dab89db8 | |||
| af2dbc01d3 | |||
| 3ac5a1cc65 | |||
| fba3e41862 | |||
| 6a821583c0 | |||
| 86d89a47a0 | |||
| 1d84468762 | |||
| 8afdec052a | |||
| b77bdf2a79 | |||
| d61d54a811 | |||
| d430aecdbd | |||
| 29a0e53978 | |||
| 05e3139f80 | |||
| 8b9ca79d5b | |||
| 24e1f4fb26 | |||
| fa33037b86 | |||
| c2fb0a294f | |||
| abd15eb111 | |||
| 352f73e7c2 | |||
| 1d8da99d5b | |||
| 8df91fce7c | |||
| 1607a0d3f7 | |||
| 57ee5cf6c2 | |||
| 6eabf37097 | |||
| 5413eb5f35 | |||
| 4aaf49b6ea | |||
| d3f22f1e14 | |||
| 51323e769d | |||
| 1fb789862d | |||
| c2c417a9fd |
@ -3,12 +3,12 @@ FROM node:$NODE_VERSION
|
||||
|
||||
# Install required tools
|
||||
RUN apt-get clean -y && \
|
||||
apt-get -qy update && \
|
||||
apt-get -y install zip && \
|
||||
apt-get clean && \
|
||||
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
|
||||
apt-get -qy update && \
|
||||
apt-get -y install zip && \
|
||||
apt-get clean && \
|
||||
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
|
||||
|
||||
WORKDIR /usr/src/app
|
||||
|
||||
COPY . .
|
||||
RUN npm install --production=false
|
||||
COPY package.json .
|
||||
RUN npm install
|
||||
|
||||
27
.buildkite/Dockerfile-make
Normal file
27
.buildkite/Dockerfile-make
Normal file
@ -0,0 +1,27 @@
|
||||
ARG NODE_JS_VERSION=${NODE_JS_VERSION:-18}
|
||||
FROM node:${NODE_JS_VERSION}
|
||||
|
||||
ARG BUILDER_UID=1000
|
||||
ARG BUILDER_GID=1000
|
||||
ENV BUILDER_USER elastic
|
||||
ENV BUILDER_GROUP elastic
|
||||
|
||||
# install zip util
|
||||
RUN apt-get clean -y && \
|
||||
apt-get update -y && \
|
||||
apt-get install -y zip
|
||||
|
||||
# Set user permissions and directory
|
||||
RUN (id -g ${BUILDER_GID} || groupadd --system -g ${BUILDER_GID} ${BUILDER_GROUP}) \
|
||||
&& (id -u ${BUILDER_UID} || useradd --system --shell /bin/bash -u ${BUILDER_UID} -g ${BUILDER_GID} -m elastic) \
|
||||
&& mkdir -p /usr/src/elasticsearch-js \
|
||||
&& chown -R ${BUILDER_UID}:${BUILDER_GID} /usr/src/
|
||||
|
||||
WORKDIR /usr/src/elasticsearch-js
|
||||
|
||||
# run remainder of commands as non-root user
|
||||
USER ${BUILDER_UID}:${BUILDER_GID}
|
||||
|
||||
# install dependencies
|
||||
COPY package.json .
|
||||
RUN npm install
|
||||
@ -2,7 +2,7 @@
|
||||
#
|
||||
# Shared cleanup routines between different steps
|
||||
#
|
||||
# Please source .ci/functions/imports.sh as a whole not just this file
|
||||
# Please source .buildkite/functions/imports.sh as a whole not just this file
|
||||
#
|
||||
# Version 1.0.0
|
||||
# - Initial version after refactor
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
#
|
||||
# Exposes a routine scripts can call to wait for a container if that container set up a health command
|
||||
#
|
||||
# Please source .ci/functions/imports.sh as a whole not just this file
|
||||
# Please source .buildkite/functions/imports.sh as a whole not just this file
|
||||
#
|
||||
# Version 1.0.1
|
||||
# - Initial version after refactor
|
||||
|
||||
@ -1,20 +1,6 @@
|
||||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* Copyright Elasticsearch B.V. and contributors
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/* global $ argv */
|
||||
@ -74,14 +60,15 @@ async function release (args) {
|
||||
|
||||
async function bump (args) {
|
||||
assert(args.length === 1, 'Bump task expects one parameter')
|
||||
const [version] = args
|
||||
let [version] = args
|
||||
const packageJson = JSON.parse(await readFile(
|
||||
join(import.meta.url, '..', 'package.json'),
|
||||
'utf8'
|
||||
))
|
||||
|
||||
if (version.split('.').length === 2) version = `${version}.0`
|
||||
const cleanVersion = semver.clean(version.includes('SNAPSHOT') ? version.split('-')[0] : version)
|
||||
assert(semver.valid(cleanVersion))
|
||||
assert(semver.valid(cleanVersion), `${cleanVersion} is not seen as a valid semver version. raw version: ${version}`)
|
||||
packageJson.version = cleanVersion
|
||||
packageJson.versionCanary = `${cleanVersion}-canary.0`
|
||||
|
||||
@ -94,7 +81,7 @@ async function bump (args) {
|
||||
const pipeline = await readFile(join(import.meta.url, '..', '.buildkite', 'pipeline.yml'), 'utf8')
|
||||
await writeFile(
|
||||
join(import.meta.url, '..', '.buildkite', 'pipeline.yml'),
|
||||
pipeline.replace(/STACK_VERSION: [0-9]+[0-9\.]*[0-9](?:\-SNAPSHOT)?/, `STACK_VERSION: ${cleanVersion}-SNAPSHOT`),
|
||||
pipeline.replace(/STACK_VERSION: [0-9]+[0-9\.]*[0-9](?:\-SNAPSHOT)?/, `STACK_VERSION: ${cleanVersion}`),
|
||||
'utf8'
|
||||
)
|
||||
}
|
||||
@ -122,8 +109,15 @@ async function codegen (args) {
|
||||
await $`rm -rf ${join(import.meta.url, '..', 'src', 'api')}`
|
||||
await $`mkdir ${join(import.meta.url, '..', 'src', 'api')}`
|
||||
await $`cp -R ${join(import.meta.url, '..', '..', 'elastic-client-generator-js', 'output')}/* ${join(import.meta.url, '..', 'src', 'api')}`
|
||||
await $`mv ${join(import.meta.url, '..', 'src', 'api', 'reference.asciidoc')} ${join(import.meta.url, '..', 'docs', 'reference.asciidoc')}`
|
||||
await $`mv ${join(import.meta.url, '..', 'src', 'api', 'reference.md')} ${join(import.meta.url, '..', 'docs', 'reference', 'api-reference.md')}`
|
||||
await $`npm run build`
|
||||
|
||||
// run docs example generation
|
||||
if (version === 'main') {
|
||||
await $`node ./scripts/generate-docs-examples.js`
|
||||
} else {
|
||||
await $`node ./scripts/generate-docs-examples.js ${version.split('.').slice(0, 2).join('.')}`
|
||||
}
|
||||
}
|
||||
|
||||
function onError (err) {
|
||||
@ -1,31 +1,32 @@
|
||||
---
|
||||
agents:
|
||||
provider: "gcp"
|
||||
image: family/core-ubuntu-2204
|
||||
memory: "8G"
|
||||
cpu: "2"
|
||||
|
||||
steps:
|
||||
- label: ":elasticsearch: :javascript: ES JavaScript ({{ matrix.nodejs }}) Test Suite: {{ matrix.suite }}"
|
||||
agents:
|
||||
provider: "gcp"
|
||||
- label: ":elasticsearch: :javascript: ES JavaScript ({{ matrix.nodejs }})"
|
||||
env:
|
||||
NODE_VERSION: "{{ matrix.nodejs }}"
|
||||
TEST_SUITE: "{{ matrix.suite }}"
|
||||
STACK_VERSION: 8.10.3-SNAPSHOT
|
||||
TEST_SUITE: "platinum"
|
||||
STACK_VERSION: 9.0.0
|
||||
GITHUB_TOKEN_PATH: "secret/ci/elastic-elasticsearch-js/github-token"
|
||||
TEST_ES_STACK: "1"
|
||||
matrix:
|
||||
setup:
|
||||
suite:
|
||||
- "free"
|
||||
- "platinum"
|
||||
nodejs:
|
||||
- "18"
|
||||
- "20"
|
||||
- "22"
|
||||
command: ./.buildkite/run-tests.sh
|
||||
artifact_paths: "./junit-output/junit-*.xml"
|
||||
- wait: ~
|
||||
continue_on_failure: true
|
||||
- label: ":junit: Test results"
|
||||
agents:
|
||||
provider: "gcp"
|
||||
image: family/core-ubuntu-2204
|
||||
plugins:
|
||||
- junit-annotate#v2.4.1:
|
||||
- junit-annotate#v2.6.0:
|
||||
artifacts: "junit-output/junit-*.xml"
|
||||
job-uuid-file-pattern: 'junit-(.*).xml'
|
||||
job-uuid-file-pattern: "junit-(.*).xml"
|
||||
fail-build-on-error: true
|
||||
failure-format: file
|
||||
|
||||
@ -9,7 +9,6 @@
|
||||
"\\.md$",
|
||||
"\\.asciidoc$",
|
||||
"^docs\\/",
|
||||
"^\\.ci\\/",
|
||||
"^scripts\\/",
|
||||
"^catalog-info\\.yaml$",
|
||||
"^test\\/unit\\/",
|
||||
|
||||
@ -10,22 +10,29 @@ export NODE_VERSION=${NODE_VERSION:-18}
|
||||
|
||||
echo "--- :javascript: Building Docker image"
|
||||
docker build \
|
||||
--file "$script_path/Dockerfile" \
|
||||
--tag elastic/elasticsearch-js \
|
||||
--build-arg NODE_VERSION="$NODE_VERSION" \
|
||||
.
|
||||
--file "$script_path/Dockerfile" \
|
||||
--tag elastic/elasticsearch-js \
|
||||
--build-arg NODE_VERSION="$NODE_VERSION" \
|
||||
.
|
||||
|
||||
echo "--- :javascript: Running $TEST_SUITE tests"
|
||||
GITHUB_TOKEN=$(vault read -field=token "$GITHUB_TOKEN_PATH")
|
||||
export GITHUB_TOKEN
|
||||
|
||||
echo "--- :javascript: Running tests"
|
||||
mkdir -p "$repo/junit-output"
|
||||
docker run \
|
||||
--network="${network_name}" \
|
||||
--env "TEST_ES_SERVER=${elasticsearch_url}" \
|
||||
--env "ELASTIC_PASSWORD=${elastic_password}" \
|
||||
--env "TEST_SUITE=${TEST_SUITE}" \
|
||||
--env "ELASTIC_USER=elastic" \
|
||||
--env "BUILDKITE=true" \
|
||||
--volume "$repo/junit-output:/junit-output" \
|
||||
--name elasticsearch-js \
|
||||
--rm \
|
||||
elastic/elasticsearch-js \
|
||||
bash -c "npm run test:integration; [ -f ./$TEST_SUITE-report-junit.xml ] && mv ./$TEST_SUITE-report-junit.xml /junit-output/junit-$BUILDKITE_JOB_ID.xml || echo 'No JUnit artifact found'"
|
||||
--network="${network_name}" \
|
||||
--env TEST_ES_STACK \
|
||||
--env STACK_VERSION \
|
||||
--env GITHUB_TOKEN \
|
||||
--env "TEST_ES_SERVER=${elasticsearch_url}" \
|
||||
--env "ELASTIC_PASSWORD=${elastic_password}" \
|
||||
--env "ELASTIC_USER=elastic" \
|
||||
--env "BUILDKITE=true" \
|
||||
--volume "/usr/src/app/node_modules" \
|
||||
--volume "$repo:/usr/src/app" \
|
||||
--volume "$repo/junit-output:/junit-output" \
|
||||
--name elasticsearch-js \
|
||||
--rm \
|
||||
elastic/elasticsearch-js \
|
||||
bash -c "npm run test:integration; [ -f ./report-junit.xml ] && mv ./report-junit.xml /junit-output/junit-$BUILDKITE_JOB_ID.xml || echo 'No JUnit artifact found'"
|
||||
|
||||
@ -1,30 +0,0 @@
|
||||
ARG NODE_JS_VERSION=${NODE_JS_VERSION:-18}
|
||||
FROM node:${NODE_JS_VERSION}
|
||||
|
||||
ARG BUILDER_UID=1000
|
||||
ARG BUILDER_GID=1000
|
||||
ENV BUILDER_USER elastic
|
||||
ENV BUILDER_GROUP elastic
|
||||
|
||||
# install zip util
|
||||
RUN apt-get clean -y && \
|
||||
apt-get update -y && \
|
||||
apt-get install -y zip
|
||||
|
||||
# Set user permissions and directory
|
||||
RUN (id -g ${BUILDER_GID} || groupadd --system -g ${BUILDER_GID} ${BUILDER_GROUP}) \
|
||||
&& (id -u ${BUILDER_UID} || useradd --system --shell /bin/bash -u ${BUILDER_UID} -g ${BUILDER_GID} -m elastic) \
|
||||
&& mkdir -p /usr/src/elasticsearch-js \
|
||||
&& chown -R ${BUILDER_UID}:${BUILDER_GID} /usr/src/
|
||||
|
||||
WORKDIR /usr/src/elasticsearch-js
|
||||
|
||||
# run remainder of commands as non-root user
|
||||
USER ${BUILDER_UID}:${BUILDER_GID}
|
||||
|
||||
# install dependencies
|
||||
COPY package.json .
|
||||
RUN npm install --production=false
|
||||
|
||||
# copy project files
|
||||
COPY . .
|
||||
214
.ci/make.sh
214
.ci/make.sh
@ -1,214 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
# ------------------------------------------------------- #
|
||||
#
|
||||
# Build entry script for elasticsearch-js
|
||||
#
|
||||
# Must be called: ./.ci/make.sh <target> <params>
|
||||
#
|
||||
# Version: 1.1.0
|
||||
#
|
||||
# Targets:
|
||||
# ---------------------------
|
||||
# assemble <VERSION> : build client artifacts with version
|
||||
# bump <VERSION> : bump client internals to version
|
||||
# bumpmatrix <VERSION> : bump stack version in test matrix to version
|
||||
# codegen <VERSION> : generate endpoints
|
||||
# docsgen <VERSION> : generate documentation
|
||||
# examplegen : generate the doc examples
|
||||
# clean : clean workspace
|
||||
#
|
||||
# ------------------------------------------------------- #
|
||||
|
||||
# ------------------------------------------------------- #
|
||||
# Bootstrap
|
||||
# ------------------------------------------------------- #
|
||||
script_path=$(dirname "$(realpath -s "$0")")
|
||||
repo=$(realpath "$script_path/../")
|
||||
|
||||
# shellcheck disable=SC1090
|
||||
CMD=$1
|
||||
TASK=$1
|
||||
TASK_ARGS=()
|
||||
VERSION=$2
|
||||
STACK_VERSION=$VERSION
|
||||
set -euo pipefail
|
||||
|
||||
product="elastic/elasticsearch-js"
|
||||
output_folder=".ci/output"
|
||||
codegen_folder=".ci/output"
|
||||
OUTPUT_DIR="$repo/${output_folder}"
|
||||
NODE_JS_VERSION=18
|
||||
WORKFLOW=${WORKFLOW-staging}
|
||||
mkdir -p "$OUTPUT_DIR"
|
||||
|
||||
echo -e "\033[34;1mINFO:\033[0m PRODUCT ${product}\033[0m"
|
||||
echo -e "\033[34;1mINFO:\033[0m VERSION ${STACK_VERSION}\033[0m"
|
||||
echo -e "\033[34;1mINFO:\033[0m OUTPUT_DIR ${OUTPUT_DIR}\033[0m"
|
||||
|
||||
case $CMD in
|
||||
clean)
|
||||
echo -e "\033[36;1mTARGET: clean workspace $output_folder\033[0m"
|
||||
rm -rf "$output_folder"
|
||||
echo -e "\033[32;1mdone.\033[0m"
|
||||
exit 0
|
||||
;;
|
||||
assemble)
|
||||
if [ -v $VERSION ]; then
|
||||
echo -e "\033[31;1mTARGET: assemble -> missing version parameter\033[0m"
|
||||
exit 1
|
||||
fi
|
||||
echo -e "\033[36;1mTARGET: assemble artifact $VERSION\033[0m"
|
||||
TASK=release
|
||||
TASK_ARGS=("$VERSION" "$output_folder")
|
||||
;;
|
||||
codegen)
|
||||
if [ -v "$VERSION" ] || [[ -z "$VERSION" ]]; then
|
||||
# fall back to branch name or `main` if no VERSION is set
|
||||
branch_name=$(git rev-parse --abbrev-ref HEAD)
|
||||
if [[ "$branch_name" =~ ^[0-9]+\.[0-9]+ ]]; then
|
||||
echo -e "\033[36;1mTARGET: codegen -> No VERSION argument found, using branch name: \`$branch_name\`\033[0m"
|
||||
VERSION="$branch_name"
|
||||
else
|
||||
echo -e "\033[36;1mTARGET: codegen -> No VERSION argument found, using \`main\`\033[0m"
|
||||
VERSION="main"
|
||||
fi
|
||||
fi
|
||||
if [ "$VERSION" = 'main' ]; then
|
||||
echo -e "\033[36;1mTARGET: codegen API $VERSION\033[0m"
|
||||
else
|
||||
echo -e "\033[36;1mTARGET: codegen API v$VERSION\033[0m"
|
||||
fi
|
||||
|
||||
TASK=codegen
|
||||
TASK_ARGS=("$VERSION")
|
||||
;;
|
||||
docsgen)
|
||||
if [ -v $VERSION ]; then
|
||||
echo -e "\033[31;1mTARGET: docsgen -> missing version parameter\033[0m"
|
||||
exit 1
|
||||
fi
|
||||
echo -e "\033[36;1mTARGET: generate docs for $VERSION\033[0m"
|
||||
TASK=codegen
|
||||
TASK_ARGS=("$VERSION" "$codegen_folder")
|
||||
;;
|
||||
examplesgen)
|
||||
echo -e "\033[36;1mTARGET: generate examples\033[0m"
|
||||
TASK=codegen
|
||||
TASK_ARGS=("$VERSION" "$codegen_folder")
|
||||
;;
|
||||
bump)
|
||||
if [ -v $VERSION ]; then
|
||||
echo -e "\033[31;1mTARGET: bump -> missing version parameter\033[0m"
|
||||
exit 1
|
||||
fi
|
||||
echo -e "\033[36;1mTARGET: bump to version $VERSION\033[0m"
|
||||
TASK=bump
|
||||
TASK_ARGS=("$VERSION")
|
||||
;;
|
||||
bumpmatrix)
|
||||
if [ -v $VERSION ]; then
|
||||
echo -e "\033[31;1mTARGET: bumpmatrix -> missing version parameter\033[0m"
|
||||
exit 1
|
||||
fi
|
||||
echo -e "\033[36;1mTARGET: bump stack in test matrix to version $VERSION\033[0m"
|
||||
TASK=bumpmatrix
|
||||
TASK_ARGS=("$VERSION")
|
||||
;;
|
||||
*)
|
||||
echo -e "\n'$CMD' is not supported right now\n"
|
||||
echo -e "\nUsage:"
|
||||
echo -e "\t $0 release \$VERSION\n"
|
||||
echo -e "\t $0 bump \$VERSION"
|
||||
echo -e "\t $0 codegen \$VERSION"
|
||||
exit 1
|
||||
esac
|
||||
|
||||
|
||||
# ------------------------------------------------------- #
|
||||
# Build Container
|
||||
# ------------------------------------------------------- #
|
||||
|
||||
echo -e "\033[34;1mINFO: building $product container\033[0m"
|
||||
|
||||
docker build \
|
||||
--file .ci/Dockerfile \
|
||||
--tag "$product" \
|
||||
--build-arg NODE_JS_VERSION="$NODE_JS_VERSION" \
|
||||
--build-arg "BUILDER_UID=$(id -u)" \
|
||||
--build-arg "BUILDER_GID=$(id -g)" \
|
||||
.
|
||||
|
||||
# ------------------------------------------------------- #
|
||||
# Run the Container
|
||||
# ------------------------------------------------------- #
|
||||
|
||||
echo -e "\033[34;1mINFO: running $product container\033[0m"
|
||||
|
||||
if [[ -z "${BUILDKITE+x}" ]] && [[ -z "${CI+x}" ]] && [[ -z "${GITHUB_ACTIONS+x}" ]]; then
|
||||
echo -e "\033[34;1mINFO: Running in local mode"
|
||||
docker run \
|
||||
-u "$(id -u):$(id -g)" \
|
||||
--volume "$repo:/usr/src/elasticsearch-js" \
|
||||
--volume /usr/src/elasticsearch-js/node_modules \
|
||||
--volume "$(realpath $repo/../elastic-client-generator-js):/usr/src/elastic-client-generator-js" \
|
||||
--env "WORKFLOW=$WORKFLOW" \
|
||||
--name make-elasticsearch-js \
|
||||
--rm \
|
||||
$product \
|
||||
/bin/bash -c "mkdir -p /usr/src/elastic-client-generator-js/output && \
|
||||
node .ci/make.mjs --task $TASK ${TASK_ARGS[*]}"
|
||||
else
|
||||
echo -e "\033[34;1mINFO: Running in CI mode"
|
||||
docker run \
|
||||
--volume "$repo:/usr/src/elasticsearch-js" \
|
||||
--volume /usr/src/elasticsearch-js/node_modules \
|
||||
-u "$(id -u):$(id -g)" \
|
||||
--env "WORKFLOW=$WORKFLOW" \
|
||||
--name make-elasticsearch-js \
|
||||
--rm \
|
||||
$product \
|
||||
/bin/bash -c "cd /usr/src && \
|
||||
git clone https://$CLIENTS_GITHUB_TOKEN@github.com/elastic/elastic-client-generator-js.git && \
|
||||
mkdir -p /usr/src/elastic-client-generator-js/output && \
|
||||
cd /usr/src/elasticsearch-js && \
|
||||
node .ci/make.mjs --task $TASK ${TASK_ARGS[*]}"
|
||||
fi
|
||||
|
||||
# ------------------------------------------------------- #
|
||||
# Post Command tasks & checks
|
||||
# ------------------------------------------------------- #
|
||||
|
||||
if [[ "$CMD" == "assemble" ]]; then
|
||||
if compgen -G ".ci/output/*" > /dev/null; then
|
||||
echo -e "\033[32;1mTARGET: successfully assembled client v$VERSION\033[0m"
|
||||
else
|
||||
echo -e "\033[31;1mTARGET: assemble failed, empty workspace!\033[0m"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ "$CMD" == "bump" ]]; then
|
||||
if [ -n "$(git status --porcelain)" ]; then
|
||||
echo -e "\033[32;1mTARGET: successfully bumped client v$VERSION\033[0m"
|
||||
else
|
||||
echo -e "\033[31;1mTARGET: failed bumped client v$VERSION\033[0m"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ "$CMD" == "codegen" ]]; then
|
||||
if [ -n "$(git status --porcelain)" ]; then
|
||||
echo -e "\033[32;1mTARGET: successfully generated client v$VERSION\033[0m"
|
||||
else
|
||||
echo -e "\033[31;1mTARGET: failed generating client v$VERSION\033[0m"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ "$CMD" == "docsgen" ]]; then
|
||||
echo "TODO"
|
||||
fi
|
||||
|
||||
if [[ "$CMD" == "examplesgen" ]]; then
|
||||
echo "TODO"
|
||||
fi
|
||||
@ -3,3 +3,9 @@ npm-debug.log
|
||||
test/benchmarks
|
||||
elasticsearch
|
||||
.git
|
||||
lib
|
||||
junit-output
|
||||
.tap
|
||||
rest-api-spec
|
||||
yaml-rest-tests
|
||||
generated-tests
|
||||
|
||||
49
.github/ISSUE_TEMPLATE/bug.md
vendored
49
.github/ISSUE_TEMPLATE/bug.md
vendored
@ -1,49 +0,0 @@
|
||||
---
|
||||
name: 🐛 Bug report
|
||||
about: Create a report to help us improve
|
||||
---
|
||||
|
||||
It's not uncommon that somebody already opened an issue or in the best case it's already fixed but not merged. That's the reason why you should [search](https://github.com/elastic/elasticsearch-js/issues) at first before submitting a new one.
|
||||
|
||||
**Please read this entire template before posting any issue. If you ignore these instructions
|
||||
and post an issue here that does not follow the instructions, your issue might be closed,
|
||||
locked, and assigned the `not reproducible` label.**
|
||||
|
||||
## 🐛 Bug Report
|
||||
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
## To Reproduce
|
||||
|
||||
Steps to reproduce the behavior:
|
||||
|
||||
Paste your code here:
|
||||
|
||||
```js
|
||||
|
||||
```
|
||||
|
||||
<!--
|
||||
In some cases, it might be challenging to reproduce the bug in a few lines of code.
|
||||
You can fork the following repository, which contains all the configuration needed
|
||||
to spin up a three nodes Elasticsearch cluster with security enabled.
|
||||
The repository also contains a preconfigured client instance that you can use to reproduce the issue.
|
||||
https://github.com/delvedor/es-reproduce-issue
|
||||
--->
|
||||
|
||||
## Expected behavior
|
||||
|
||||
A clear and concise description of what you expected to happen.
|
||||
|
||||
Paste the results here:
|
||||
|
||||
```js
|
||||
|
||||
```
|
||||
|
||||
## Your Environment
|
||||
|
||||
- *node version*: 6,8,10
|
||||
- `@elastic/elasticsearch` *version*: >=7.0.0
|
||||
- *os*: Mac, Windows, Linux
|
||||
- *any other relevant information*
|
||||
66
.github/ISSUE_TEMPLATE/bug.yaml
vendored
Normal file
66
.github/ISSUE_TEMPLATE/bug.yaml
vendored
Normal file
@ -0,0 +1,66 @@
|
||||
---
|
||||
name: 🐛 Bug report
|
||||
description: Create a report to help us improve
|
||||
labels: ["Category: Bug"]
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
It's not uncommon that somebody already opened an issue or in the best case it's already fixed but not merged. That's the reason why you should [search](https://github.com/elastic/elasticsearch-js/issues) at first before submitting a new one.
|
||||
|
||||
**Please read this entire template before posting any issue. If you ignore these instructions
|
||||
and post an issue here that does not follow the instructions, your issue might be closed,
|
||||
locked, and assigned the `Category: Not an issue` label.**
|
||||
|
||||
- type: textarea
|
||||
id: bug-report
|
||||
attributes:
|
||||
label: 🐛 Bug report
|
||||
description: A clear and concise description of what the bug is.
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: reproduction
|
||||
attributes:
|
||||
label: To reproduce
|
||||
description: Steps to reproduce the behavior
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: expected
|
||||
attributes:
|
||||
label: Expected behavior
|
||||
description: A clear and concise description of what you expected to happen.
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: input
|
||||
id: node-js-version
|
||||
attributes:
|
||||
label: Node.js version
|
||||
placeholder: 18.x, 20.x, etc.
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: input
|
||||
id: client-version
|
||||
attributes:
|
||||
label: "@elastic/elasticsearch version"
|
||||
placeholder: 7.17.0, 8.14.1, etc.
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: input
|
||||
id: os
|
||||
attributes:
|
||||
label: Operating system
|
||||
placeholder: Ubuntu 22.04, macOS, etc.
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: input
|
||||
id: env-info
|
||||
attributes:
|
||||
label: Any other relevant environment information
|
||||
22
.github/ISSUE_TEMPLATE/feature.md
vendored
22
.github/ISSUE_TEMPLATE/feature.md
vendored
@ -1,22 +0,0 @@
|
||||
---
|
||||
name: 🚀 Feature Proposal
|
||||
about: Submit a proposal for a new feature
|
||||
---
|
||||
|
||||
It's not uncommon that somebody already opened an issue or in the best case it's already fixed but not merged. That's the reason why you should [search](https://github.com/elastic/elasticsearch-js/issues) at first before submitting a new one.
|
||||
|
||||
**Please read this entire template before posting any issue. If you ignore these instructions
|
||||
and post an issue here that does not follow the instructions, your issue might be closed,
|
||||
locked, and assigned the `invalid` label.**
|
||||
|
||||
## 🚀 Feature Proposal
|
||||
|
||||
A clear and concise description of what the feature is.
|
||||
|
||||
## Motivation
|
||||
|
||||
Please outline the motivation for the proposal.
|
||||
|
||||
## Example
|
||||
|
||||
Please provide an example for how this feature would be used.
|
||||
33
.github/ISSUE_TEMPLATE/feature.yaml
vendored
Normal file
33
.github/ISSUE_TEMPLATE/feature.yaml
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
---
|
||||
name: 🚀 Feature Proposal
|
||||
description: Submit a proposal for a new feature
|
||||
labels: ["Category: Feature"]
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
It's not uncommon that somebody already opened an issue or in the best case it's already fixed but not merged. That's the reason why you should [search](https://github.com/elastic/elasticsearch-js/issues) at first before submitting a new one.
|
||||
|
||||
**Please read this entire template before posting any issue. If you ignore these instructions
|
||||
and post an issue here that does not follow the instructions, your issue might be closed,
|
||||
locked, and assigned the `Category: Not an issue` label.**
|
||||
|
||||
- type: textarea
|
||||
id: feature-proposal
|
||||
attributes:
|
||||
label: 🚀 Feature Proposal
|
||||
description: A clear and concise description of what the feature is.
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: motivation
|
||||
attributes:
|
||||
label: Motivation
|
||||
description: Please outline the motivation for the proposal.
|
||||
|
||||
- type: textarea
|
||||
id: example
|
||||
attributes:
|
||||
label: Example
|
||||
description: Please provide an example for how this feature would be used.
|
||||
10
.github/ISSUE_TEMPLATE/question.md
vendored
10
.github/ISSUE_TEMPLATE/question.md
vendored
@ -1,10 +0,0 @@
|
||||
---
|
||||
name: 💬 Questions / Help
|
||||
about: If you have questions, please check our Gitter or Help repo
|
||||
---
|
||||
|
||||
## 💬 Questions and Help
|
||||
|
||||
### Please note that this issue tracker is not a help forum and this issue may be closed.
|
||||
|
||||
It's not uncommon that somebody already opened an issue or in the best case it's already fixed but not merged. That's the reason why you should [search](https://github.com/elastic/elasticsearch-js/issues) at first before submitting a new one.
|
||||
21
.github/ISSUE_TEMPLATE/question.yaml
vendored
Normal file
21
.github/ISSUE_TEMPLATE/question.yaml
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
---
|
||||
name: 💬 Questions / Help
|
||||
description: If you have questions, please check our community forum or support
|
||||
labels: ["Category: Question"]
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
### Please note that this issue tracker is not a help forum and this issue may be closed.
|
||||
|
||||
Please check our [community forum](https://discuss.elastic.co/) or [contact Elastic support](https://www.elastic.co/support) if your issue is not specifically related to the documented functionality of this client library.
|
||||
|
||||
It's not uncommon that somebody already opened an issue or in the best case it's already fixed but not merged. That's the reason why you should [search](https://github.com/elastic/elasticsearch-js/issues) at first before submitting a new one.
|
||||
|
||||
- type: textarea
|
||||
id: question
|
||||
attributes:
|
||||
label: Question
|
||||
description: Your question or comment
|
||||
validations:
|
||||
required: true
|
||||
56
.github/ISSUE_TEMPLATE/regression.md
vendored
56
.github/ISSUE_TEMPLATE/regression.md
vendored
@ -1,56 +0,0 @@
|
||||
---
|
||||
name: 💥 Regression Report
|
||||
about: Report unexpected behavior that worked in previous versions
|
||||
---
|
||||
|
||||
It's not uncommon that somebody already opened an issue or in the best case it's already fixed but not merged. That's the reason why you should [search](https://github.com/elastic/elasticsearch-js/issues) at first before submitting a new one.
|
||||
|
||||
**Please read this entire template before posting any issue. If you ignore these instructions
|
||||
and post an issue here that does not follow the instructions, your issue might be closed,
|
||||
locked, and assigned the `invalid` label.**
|
||||
|
||||
## 💥 Regression Report
|
||||
|
||||
A clear and concise description of what the regression is.
|
||||
|
||||
## Last working version
|
||||
|
||||
Worked up to version:
|
||||
|
||||
Stopped working in version:
|
||||
|
||||
## To Reproduce
|
||||
|
||||
Steps to reproduce the behavior:
|
||||
|
||||
Paste your code here:
|
||||
|
||||
```js
|
||||
|
||||
```
|
||||
|
||||
<!--
|
||||
In some cases, it might be challenging to reproduce the bug in a few lines of code.
|
||||
You can fork the following repository, which contains all the configuration needed
|
||||
to spin up a three nodes Elasticsearch cluster with security enabled.
|
||||
The repository also contains a preconfigured client instance that you can use to reproduce the issue.
|
||||
https://github.com/delvedor/es-reproduce-issue
|
||||
--->
|
||||
|
||||
## Expected behavior
|
||||
|
||||
A clear and concise description of what you expected to happen.
|
||||
|
||||
Paste the results here:
|
||||
|
||||
```js
|
||||
|
||||
```
|
||||
|
||||
## Your Environment
|
||||
|
||||
- *node version*: 6,8,10
|
||||
- `@elastic/elasticsearch` *version*: >=7.0.0
|
||||
- *typescript version*: 4.x (if applicable)
|
||||
- *os*: Mac, Windows, Linux
|
||||
- *any other relevant information*
|
||||
92
.github/ISSUE_TEMPLATE/regression.yaml
vendored
Normal file
92
.github/ISSUE_TEMPLATE/regression.yaml
vendored
Normal file
@ -0,0 +1,92 @@
|
||||
---
|
||||
name: 💥 Regression Report
|
||||
description: Report unexpected behavior that worked in previous versions
|
||||
labels: ["Category: Bug"]
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
It's not uncommon that somebody already opened an issue or in the best case it's already fixed but not merged. That's the reason why you should [search](https://github.com/elastic/elasticsearch-js/issues) at first before submitting a new one.
|
||||
|
||||
**Please read this entire template before posting any issue. If you ignore these instructions
|
||||
and post an issue here that does not follow the instructions, your issue might be closed,
|
||||
locked, and assigned the `Category: Not an issue` label.**
|
||||
|
||||
- type: textarea
|
||||
id: report
|
||||
attributes:
|
||||
label: Regression report
|
||||
description: A clear and concise description of what the regression is.
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: input
|
||||
id: last-working-version
|
||||
attributes:
|
||||
label: Last working version
|
||||
description: Version of `@elastic/elasticsearch` where this last worked.
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: to-reproduce
|
||||
attributes:
|
||||
label: To reproduce
|
||||
description: |
|
||||
Paste your code here that shows how to reproduce the behavior.
|
||||
|
||||
In some cases, it might be challenging to reproduce the bug in a few lines of code.
|
||||
You can fork the following repository, which contains all the configuration needed to spin up a three nodes Elasticsearch cluster with security enabled.
|
||||
[This repository](https://github.com/delvedor/es-reproduce-issue) also contains a preconfigured client instance that you can use to reproduce the issue.
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: expected-behavior
|
||||
attributes:
|
||||
label: Expected behavior
|
||||
description: A clear and concise description of what you expected to happen.
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: input
|
||||
id: node-version
|
||||
attributes:
|
||||
label: Node.js version
|
||||
description: What version of Node.js you are using (`node --version`).
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: input
|
||||
id: typescript-version
|
||||
attributes:
|
||||
label: TypeScript version
|
||||
description: TypeScript version you are using, if applicable.
|
||||
|
||||
- type: input
|
||||
id: elasticsearch-client-version
|
||||
attributes:
|
||||
label: Elasticsearch client version
|
||||
description: What version of `@elastic/elasticsearch` and `@elastic/transport` you are using (`npm ls -a | grep '@elastic'`).
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: input
|
||||
id: elasticsearch-version
|
||||
attributes:
|
||||
label: Elasticsearch server version
|
||||
description: What version of Elasticsearch you are using.
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: input
|
||||
id: operating-system
|
||||
attributes:
|
||||
label: Operating system
|
||||
description: What operating system you are running.
|
||||
placeholder: e.g. Linux, MacOS, Windows
|
||||
|
||||
- type: textarea
|
||||
id: env-info
|
||||
attributes:
|
||||
label: Any other relevant environment information.
|
||||
6
.github/ISSUE_TEMPLATE/security.md
vendored
6
.github/ISSUE_TEMPLATE/security.md
vendored
@ -1,6 +0,0 @@
|
||||
---
|
||||
name: 👮 Security Issue
|
||||
about: Responsible Disclosure
|
||||
---
|
||||
|
||||
If you want to report a security issue, please take a look at [elastic/security](https://www.elastic.co/community/security).
|
||||
8
.github/ISSUE_TEMPLATE/security.yaml
vendored
Normal file
8
.github/ISSUE_TEMPLATE/security.yaml
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
---
|
||||
name: 👮 Security Issue
|
||||
description: Responsible disclosure
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
If you want to report a security issue, please take a look at [elastic/security](https://www.elastic.co/community/security).
|
||||
222
.github/make.sh
vendored
Executable file
222
.github/make.sh
vendored
Executable file
@ -0,0 +1,222 @@
|
||||
#!/usr/bin/env bash
|
||||
# ------------------------------------------------------- #
|
||||
#
|
||||
# Build entry script for elasticsearch-js
|
||||
#
|
||||
# Must be called: ./.github/make.sh <target> <params>
|
||||
#
|
||||
# Version: 1.1.0
|
||||
#
|
||||
# Targets:
|
||||
# ---------------------------
|
||||
# assemble <VERSION> : build client artifacts with version
|
||||
# bump <VERSION> : bump client internals to version
|
||||
# bumpmatrix <VERSION> : bump stack version in test matrix to version
|
||||
# codegen <VERSION> : generate endpoints
|
||||
# docsgen <VERSION> : generate documentation
|
||||
# examplegen : generate the doc examples
|
||||
# clean : clean workspace
|
||||
#
|
||||
# ------------------------------------------------------- #
|
||||
|
||||
# ------------------------------------------------------- #
|
||||
# Bootstrap
|
||||
# ------------------------------------------------------- #
|
||||
script_path=$(dirname "$(realpath -s "$0")")
|
||||
repo=$(realpath "$script_path/../")
|
||||
|
||||
# shellcheck disable=SC1090
|
||||
CMD=$1
|
||||
TASK=$1
|
||||
TASK_ARGS=()
|
||||
VERSION=$2
|
||||
STACK_VERSION=$VERSION
|
||||
set -euo pipefail
|
||||
|
||||
product="elastic/elasticsearch-js"
|
||||
output_folder=".buildkite/output"
|
||||
codegen_folder=".buildkite/output"
|
||||
OUTPUT_DIR="$repo/${output_folder}"
|
||||
NODE_JS_VERSION=22
|
||||
WORKFLOW=${WORKFLOW-staging}
|
||||
mkdir -p "$OUTPUT_DIR"
|
||||
|
||||
echo -e "\033[34;1mINFO:\033[0m PRODUCT ${product}\033[0m"
|
||||
echo -e "\033[34;1mINFO:\033[0m VERSION ${STACK_VERSION}\033[0m"
|
||||
echo -e "\033[34;1mINFO:\033[0m OUTPUT_DIR ${OUTPUT_DIR}\033[0m"
|
||||
|
||||
case $CMD in
|
||||
clean)
|
||||
echo -e "\033[36;1mTARGET: clean workspace $output_folder\033[0m"
|
||||
rm -rf "$output_folder"
|
||||
echo -e "\033[32;1mdone.\033[0m"
|
||||
exit 0
|
||||
;;
|
||||
assemble)
|
||||
if [ -v $VERSION ]; then
|
||||
echo -e "\033[31;1mTARGET: assemble -> missing version parameter\033[0m"
|
||||
exit 1
|
||||
fi
|
||||
echo -e "\033[36;1mTARGET: assemble artifact $VERSION\033[0m"
|
||||
TASK=release
|
||||
TASK_ARGS=("$VERSION" "$output_folder")
|
||||
;;
|
||||
codegen)
|
||||
if [ -v "$VERSION" ] || [[ -z "$VERSION" ]]; then
|
||||
# fall back to branch name or `main` if no VERSION is set
|
||||
branch_name=$(git rev-parse --abbrev-ref HEAD)
|
||||
if [[ "$branch_name" =~ ^[0-9]+\.([0-9]+|x) ]]; then
|
||||
echo -e "\033[36;1mTARGET: codegen -> No VERSION argument found, using branch name: \`$branch_name\`\033[0m"
|
||||
VERSION="$branch_name"
|
||||
else
|
||||
echo -e "\033[36;1mTARGET: codegen -> No VERSION argument found, using \`main\`\033[0m"
|
||||
VERSION="main"
|
||||
fi
|
||||
fi
|
||||
if [ "$VERSION" = 'main' ]; then
|
||||
echo -e "\033[36;1mTARGET: codegen API $VERSION\033[0m"
|
||||
else
|
||||
echo -e "\033[36;1mTARGET: codegen API v$VERSION\033[0m"
|
||||
fi
|
||||
|
||||
TASK=codegen
|
||||
TASK_ARGS=("$VERSION")
|
||||
;;
|
||||
docsgen)
|
||||
if [ -v $VERSION ]; then
|
||||
echo -e "\033[31;1mTARGET: docsgen -> missing version parameter\033[0m"
|
||||
exit 1
|
||||
fi
|
||||
echo -e "\033[36;1mTARGET: generate docs for $VERSION\033[0m"
|
||||
TASK=codegen
|
||||
TASK_ARGS=("$VERSION" "$codegen_folder")
|
||||
;;
|
||||
examplesgen)
|
||||
echo -e "\033[36;1mTARGET: generate examples\033[0m"
|
||||
TASK=codegen
|
||||
TASK_ARGS=("$VERSION" "$codegen_folder")
|
||||
;;
|
||||
bump)
|
||||
if [ -v $VERSION ]; then
|
||||
echo -e "\033[31;1mTARGET: bump -> missing version parameter\033[0m"
|
||||
exit 1
|
||||
fi
|
||||
echo -e "\033[36;1mTARGET: bump to version $VERSION\033[0m"
|
||||
TASK=bump
|
||||
TASK_ARGS=("$VERSION")
|
||||
;;
|
||||
bumpmatrix)
|
||||
if [ -v $VERSION ]; then
|
||||
echo -e "\033[31;1mTARGET: bumpmatrix -> missing version parameter\033[0m"
|
||||
exit 1
|
||||
fi
|
||||
echo -e "\033[36;1mTARGET: bump stack in test matrix to version $VERSION\033[0m"
|
||||
TASK=bumpmatrix
|
||||
TASK_ARGS=("$VERSION")
|
||||
;;
|
||||
*)
|
||||
echo -e "\n'$CMD' is not supported right now\n"
|
||||
echo -e "\nUsage:"
|
||||
echo -e "\t $0 release \$VERSION\n"
|
||||
echo -e "\t $0 bump \$VERSION"
|
||||
echo -e "\t $0 codegen \$VERSION"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
# ------------------------------------------------------- #
|
||||
# Build Container
|
||||
# ------------------------------------------------------- #
|
||||
|
||||
echo -e "\033[34;1mINFO: building $product container\033[0m"
|
||||
|
||||
docker build \
|
||||
--file .buildkite/Dockerfile-make \
|
||||
--tag "$product" \
|
||||
--build-arg NODE_JS_VERSION="$NODE_JS_VERSION" \
|
||||
--build-arg "BUILDER_UID=$(id -u)" \
|
||||
--build-arg "BUILDER_GID=$(id -g)" \
|
||||
.
|
||||
|
||||
# ------------------------------------------------------- #
|
||||
# Run the Container
|
||||
# ------------------------------------------------------- #
|
||||
|
||||
echo -e "\033[34;1mINFO: running $product container\033[0m"
|
||||
|
||||
if [[ -z "${BUILDKITE+x}" ]] && [[ -z "${CI+x}" ]] && [[ -z "${GITHUB_ACTIONS+x}" ]]; then
|
||||
echo -e "\033[34;1mINFO: Running in local mode"
|
||||
docker run \
|
||||
-u "$(id -u):$(id -g)" \
|
||||
--volume "$repo:/usr/src/elasticsearch-js" \
|
||||
--volume /usr/src/elasticsearch-js/node_modules \
|
||||
--volume "$(realpath "$repo/../elastic-client-generator-js"):/usr/src/elastic-client-generator-js" \
|
||||
--env "WORKFLOW=$WORKFLOW" \
|
||||
--name make-elasticsearch-js \
|
||||
--rm \
|
||||
$product \
|
||||
/bin/bash -c "mkdir -p /usr/src/elastic-client-generator-js/output && \
|
||||
node .buildkite/make.mjs --task $TASK ${TASK_ARGS[*]}"
|
||||
else
|
||||
echo -e "\033[34;1mINFO: Running in CI mode"
|
||||
|
||||
# determine branch to clone
|
||||
GENERATOR_BRANCH="main"
|
||||
if [[ "$VERSION" == 8.* ]]; then
|
||||
GENERATOR_BRANCH="8.x"
|
||||
fi
|
||||
echo -e "\033[34;1mINFO: Generator branch: $GENERATOR_BRANCH"
|
||||
|
||||
docker run \
|
||||
--volume "$repo:/usr/src/elasticsearch-js" \
|
||||
--volume /usr/src/elasticsearch-js/node_modules \
|
||||
-u "$(id -u):$(id -g)" \
|
||||
--env "WORKFLOW=$WORKFLOW" \
|
||||
--name make-elasticsearch-js \
|
||||
--rm \
|
||||
$product \
|
||||
/bin/bash -c "cd /usr/src && \
|
||||
git clone --branch $GENERATOR_BRANCH https://$CLIENTS_GITHUB_TOKEN@github.com/elastic/elastic-client-generator-js.git && \
|
||||
mkdir -p /usr/src/elastic-client-generator-js/output && \
|
||||
cd /usr/src/elasticsearch-js && \
|
||||
node .buildkite/make.mjs --task $TASK ${TASK_ARGS[*]}"
|
||||
fi
|
||||
|
||||
# ------------------------------------------------------- #
|
||||
# Post Command tasks & checks
|
||||
# ------------------------------------------------------- #
|
||||
|
||||
if [[ "$CMD" == "assemble" ]]; then
|
||||
if compgen -G ".buildkite/output/*" >/dev/null; then
|
||||
echo -e "\033[32;1mTARGET: successfully assembled client v$VERSION\033[0m"
|
||||
else
|
||||
echo -e "\033[31;1mTARGET: assemble failed, empty workspace!\033[0m"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ "$CMD" == "bump" ]]; then
|
||||
if [ -n "$(git status --porcelain)" ]; then
|
||||
echo -e "\033[32;1mTARGET: successfully bumped client v$VERSION\033[0m"
|
||||
else
|
||||
echo -e "\033[31;1mTARGET: failed bumped client v$VERSION\033[0m"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ "$CMD" == "codegen" ]]; then
|
||||
if [ -n "$(git status --porcelain)" ]; then
|
||||
echo -e "\033[32;1mTARGET: successfully generated client v$VERSION\033[0m"
|
||||
else
|
||||
echo -e "\033[31;1mTARGET: failed generating client v$VERSION\033[0m"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ "$CMD" == "docsgen" ]]; then
|
||||
echo "TODO"
|
||||
fi
|
||||
|
||||
if [[ "$CMD" == "examplesgen" ]]; then
|
||||
echo "TODO"
|
||||
fi
|
||||
26
.github/stale.yml
vendored
26
.github/stale.yml
vendored
@ -1,26 +0,0 @@
|
||||
# Number of days of inactivity before an issue becomes stale
|
||||
daysUntilStale: 15
|
||||
|
||||
# Number of days of inactivity before a stale issue is closed
|
||||
daysUntilClose: 7
|
||||
|
||||
# Issues with these labels will never be considered stale
|
||||
exemptLabels:
|
||||
- "discussion"
|
||||
- "feature request"
|
||||
- "bug"
|
||||
- "todo"
|
||||
- "good first issue"
|
||||
|
||||
# Label to use when marking an issue as stale
|
||||
staleLabel: stale
|
||||
|
||||
# Comment to post when marking an issue as stale. Set to `false` to disable
|
||||
markComment: |
|
||||
We understand that this might be important for you, but this issue has been automatically marked as stale because it has not had recent activity either from our end or yours.
|
||||
It will be closed if no further activity occurs, please write a comment if you would like to keep this going.
|
||||
|
||||
Note: in the past months we have built a new client, that has just landed in master. If you want to open an issue or a pr for the legacy client, you should do that in https://github.com/elastic/elasticsearch-js-legacy
|
||||
|
||||
# Comment to post when closing a stale issue. Set to `false` to disable
|
||||
closeComment: false
|
||||
19
.github/workflows/docs-build.yml
vendored
Normal file
19
.github/workflows/docs-build.yml
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
name: docs-build
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
pull_request_target: ~
|
||||
merge_group: ~
|
||||
|
||||
jobs:
|
||||
docs-preview:
|
||||
uses: elastic/docs-builder/.github/workflows/preview-build.yml@main
|
||||
with:
|
||||
path-pattern: docs/**
|
||||
permissions:
|
||||
deployments: write
|
||||
id-token: write
|
||||
contents: read
|
||||
pull-requests: read
|
||||
14
.github/workflows/docs-cleanup.yml
vendored
Normal file
14
.github/workflows/docs-cleanup.yml
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
name: docs-cleanup
|
||||
|
||||
on:
|
||||
pull_request_target:
|
||||
types:
|
||||
- closed
|
||||
|
||||
jobs:
|
||||
docs-preview:
|
||||
uses: elastic/docs-builder/.github/workflows/preview-cleanup.yml@main
|
||||
permissions:
|
||||
contents: none
|
||||
id-token: write
|
||||
deployments: write
|
||||
84
.github/workflows/nodejs.yml
vendored
84
.github/workflows/nodejs.yml
vendored
@ -9,15 +9,17 @@ jobs:
|
||||
name: Detect files changed
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
src-only: '${{ steps.changes.outputs.src-only }}'
|
||||
src-only: "${{ steps.changes.outputs.src-only }}"
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: dorny/paths-filter/@v2.11.1
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
|
||||
with:
|
||||
persist-credentials: false
|
||||
- uses: dorny/paths-filter/@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
|
||||
id: changes
|
||||
with:
|
||||
filters: |
|
||||
src-only:
|
||||
- '!(**/*.{md,asciidoc,txt}|*.{md,asciidoc,txt}|{docs,.ci,.buildkite,scripts}/**/*|catalog-info.yaml)'
|
||||
- '!(**/*.{md,asciidoc,txt}|*.{md,asciidoc,txt}|{docs,.buildkite,scripts}/**/*|catalog-info.yaml)'
|
||||
- '.github/workflows/**'
|
||||
|
||||
test:
|
||||
@ -30,24 +32,19 @@ jobs:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
node-version: [18.x, 20.x]
|
||||
node-version: [18.x, 20.x, 22.x, 23.x]
|
||||
os: [ubuntu-latest, windows-latest, macOS-latest]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: Use Node.js ${{ matrix.node-version }}
|
||||
uses: actions/setup-node@v3
|
||||
uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
|
||||
# workaround for failing tests on Node.js 14.x
|
||||
# see https://github.com/actions/setup-node/issues/411
|
||||
- name: Force install specific npm version
|
||||
run: |
|
||||
npm install --global npm@8.3.1
|
||||
npm install --global npm@9.7.1
|
||||
|
||||
- name: Install
|
||||
run: |
|
||||
npm install
|
||||
@ -60,21 +57,23 @@ jobs:
|
||||
run: |
|
||||
npm run test:unit
|
||||
|
||||
- name: ECMAScript module test
|
||||
run: |
|
||||
npm run test:esm
|
||||
|
||||
license:
|
||||
name: License check
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
node-version: [20.x]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Use Node.js ${{ matrix.node-version }}
|
||||
uses: actions/setup-node@v3
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
persist-credentials: false
|
||||
|
||||
- name: Use Node.js
|
||||
uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4
|
||||
with:
|
||||
node-version: 22.x
|
||||
|
||||
- name: Install
|
||||
run: |
|
||||
@ -83,3 +82,42 @@ jobs:
|
||||
- name: License checker
|
||||
run: |
|
||||
npm run license-checker
|
||||
|
||||
- name: SPDX header check
|
||||
run: npm run license-header
|
||||
|
||||
test-bun:
|
||||
name: Test Bun
|
||||
runs-on: ${{ matrix.os }}
|
||||
needs: paths-filter
|
||||
# only run if code relevant to unit tests was changed
|
||||
if: needs.paths-filter.outputs.src-only == 'true'
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ubuntu-latest, windows-latest, macOS-latest]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: Use Bun
|
||||
uses: oven-sh/setup-bun@4bc047ad259df6fc24a6c9b0f9a0cb08cf17fbe5 # v2
|
||||
|
||||
- name: Install
|
||||
run: |
|
||||
bun install
|
||||
|
||||
- name: Lint
|
||||
run: |
|
||||
bun run lint
|
||||
|
||||
- name: Unit test
|
||||
run: |
|
||||
bun run test:unit-bun
|
||||
|
||||
- name: ECMAScript module test
|
||||
run: |
|
||||
bun run test:esm
|
||||
|
||||
41
.github/workflows/npm-publish.yml
vendored
Normal file
41
.github/workflows/npm-publish.yml
vendored
Normal file
@ -0,0 +1,41 @@
|
||||
name: Publish Package to npm
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
branch:
|
||||
description: "Git branch to build and publish"
|
||||
required: true
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
id-token: write
|
||||
steps:
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
|
||||
with:
|
||||
persist-credentials: false
|
||||
ref: ${{ github.event.inputs.branch }}
|
||||
- uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4
|
||||
with:
|
||||
node-version: "22.x"
|
||||
registry-url: "https://registry.npmjs.org"
|
||||
- run: npm install -g npm
|
||||
- run: npm install
|
||||
- run: npm test
|
||||
- run: npm publish --provenance --access public --tag alpha
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
- name: Publish version on GitHub
|
||||
run: |
|
||||
version=$(jq -r .version package.json)
|
||||
gh release create \
|
||||
-n "This is a 9.0.0 pre-release alpha. Changes may not be stable." \
|
||||
--latest=false \
|
||||
--prerelease \
|
||||
--target "$BRANCH_NAME" \
|
||||
--title "v$version" \
|
||||
"v$version"
|
||||
env:
|
||||
BRANCH_NAME: ${{ github.event.inputs.branch }}
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
12
.github/workflows/stale.yml
vendored
12
.github/workflows/stale.yml
vendored
@ -1,21 +1,21 @@
|
||||
---
|
||||
name: 'Close stale issues and PRs'
|
||||
name: "Close stale issues and PRs"
|
||||
on:
|
||||
schedule:
|
||||
- cron: '30 1 * * *'
|
||||
- cron: "30 1 * * *"
|
||||
|
||||
jobs:
|
||||
stale:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/stale@v8
|
||||
- uses: actions/stale@5bef64f19d7facfb25b37b414482c7164d639639 # v9
|
||||
with:
|
||||
stale-issue-label: stale
|
||||
stale-pr-label: stale
|
||||
days-before-stale: 90
|
||||
days-before-close: 14
|
||||
exempt-issue-labels: 'good first issue'
|
||||
exempt-issue-labels: "good first issue,tracking"
|
||||
close-issue-label: closed-stale
|
||||
close-pr-label: closed-stale
|
||||
stale-issue-message: 'This issue is stale because it has been open 90 days with no activity. Remove the `stale` label, or leave a comment, or this will be closed in 14 days.'
|
||||
stale-pr-message: 'This pull request is stale because it has been open 90 days with no activity. Remove the `stale` label, or leave a comment, or this will be closed in 14 days.'
|
||||
stale-issue-message: "This issue is stale because it has been open 90 days with no activity. Remove the `stale` label, or leave a comment, or this will be closed in 14 days."
|
||||
stale-pr-message: "This pull request is stale because it has been open 90 days with no activity. Remove the `stale` label, or leave a comment, or this will be closed in 14 days."
|
||||
|
||||
9
.gitignore
vendored
9
.gitignore
vendored
@ -63,3 +63,12 @@ test/bundlers/**/bundle.js
|
||||
test/bundlers/parcel-test/.parcel-cache
|
||||
|
||||
lib
|
||||
junit-output
|
||||
bun.lockb
|
||||
test-results
|
||||
processinfo
|
||||
.tap
|
||||
rest-api-spec
|
||||
yaml-rest-tests
|
||||
generated-tests
|
||||
schema
|
||||
|
||||
@ -64,7 +64,6 @@ test
|
||||
scripts
|
||||
|
||||
# ci configuration
|
||||
.ci
|
||||
.travis.yml
|
||||
.buildkite
|
||||
certs
|
||||
@ -73,3 +72,8 @@ CODE_OF_CONDUCT.md
|
||||
CONTRIBUTING.md
|
||||
|
||||
src
|
||||
bun.lockb
|
||||
.tap
|
||||
rest-api-spec
|
||||
yaml-rest-tests
|
||||
generated-tests
|
||||
|
||||
11
Makefile
11
Makefile
@ -1,11 +0,0 @@
|
||||
.PHONY: integration-setup
|
||||
integration-setup: integration-cleanup
|
||||
DETACH=true .ci/run-elasticsearch.sh
|
||||
|
||||
.PHONY: integration-cleanup
|
||||
integration-cleanup:
|
||||
docker container rm --force --volumes instance || true
|
||||
|
||||
.PHONY: integration
|
||||
integration: integration-setup
|
||||
npm run test:integration
|
||||
19
README.md
19
README.md
@ -21,6 +21,25 @@ of the getting started documentation.
|
||||
Refer to the [Connecting section](https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/getting-started-js.html#_connecting)
|
||||
of the getting started documentation.
|
||||
|
||||
## Compatibility
|
||||
|
||||
The Elasticsearch client is compatible with currently maintained JS versions.
|
||||
|
||||
Language clients are forward compatible; meaning that clients support
|
||||
communicating with greater or equal minor versions of Elasticsearch without
|
||||
breaking. It does not mean that the client automatically supports new features
|
||||
of newer Elasticsearch versions; it is only possible after a release of a new
|
||||
client version. For example, a 8.12 client version won't automatically support
|
||||
the new features of the 8.13 version of Elasticsearch, the 8.13 client version
|
||||
is required for that. Elasticsearch language clients are only backwards
|
||||
compatible with default distributions and without guarantees made.
|
||||
|
||||
| Elasticsearch Version | Elasticsearch-JS Branch | Supported |
|
||||
| --------------------- | ------------------------ | --------- |
|
||||
| main | main | |
|
||||
| 8.x | 8.x | 8.x |
|
||||
| 7.x | 7.x | 7.17 |
|
||||
|
||||
## Usage
|
||||
|
||||
* [Creating an index](https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/getting-started-js.html#_creating_an_index)
|
||||
|
||||
@ -6,7 +6,7 @@ metadata:
|
||||
name: elasticsearch-js
|
||||
spec:
|
||||
type: library
|
||||
owner: group:clients-team
|
||||
owner: group:devtools-team
|
||||
lifecycle: production
|
||||
|
||||
---
|
||||
@ -18,7 +18,7 @@ metadata:
|
||||
description: elasticsearch-js - integration tests
|
||||
spec:
|
||||
type: buildkite-pipeline
|
||||
owner: group:clients-team
|
||||
owner: group:devtools-team
|
||||
system: buildkite
|
||||
implementation:
|
||||
apiVersion: buildkite.elastic.dev/v1
|
||||
@ -28,8 +28,11 @@ spec:
|
||||
spec:
|
||||
repository: elastic/elasticsearch-js
|
||||
pipeline_file: .buildkite/pipeline.yml
|
||||
env:
|
||||
ELASTIC_SLACK_NOTIFICATIONS_ENABLED: "true"
|
||||
SLACK_NOTIFICATIONS_CHANNEL: "#devtools-notify-javascript"
|
||||
teams:
|
||||
clients-team:
|
||||
devtools-team:
|
||||
access_level: MANAGE_BUILD_AND_READ
|
||||
everyone:
|
||||
access_level: READ_ONLY
|
||||
@ -37,14 +40,17 @@ spec:
|
||||
build_pull_requests: false
|
||||
build_branches: false
|
||||
cancel_intermediate_builds: true
|
||||
cancel_intermediate_builds_branch_filter: '!main'
|
||||
cancel_intermediate_builds_branch_filter: "!main"
|
||||
schedules:
|
||||
main_semi_daily:
|
||||
branch: 'main'
|
||||
cronline: '0 */12 * * *'
|
||||
8_9_semi_daily:
|
||||
branch: '8.9'
|
||||
cronline: '0 */12 * * *'
|
||||
8_8_daily:
|
||||
branch: '8.8'
|
||||
cronline: '@daily'
|
||||
main:
|
||||
branch: "main"
|
||||
cronline: "@daily"
|
||||
8_x:
|
||||
branch: "8.x"
|
||||
cronline: "@daily"
|
||||
8_17:
|
||||
branch: "8.17"
|
||||
cronline: "@daily"
|
||||
8_18:
|
||||
branch: "8.18"
|
||||
cronline: "@daily"
|
||||
|
||||
@ -1,106 +0,0 @@
|
||||
[[advanced-config]]
|
||||
=== Advanced configuration
|
||||
|
||||
If you need to customize the client behavior heavily, you are in the right
|
||||
place! The client enables you to customize the following internals:
|
||||
|
||||
* `ConnectionPool` class
|
||||
* `Connection` class
|
||||
* `Serializer` class
|
||||
|
||||
NOTE: For information about the `Transport` class, refer to <<transport>>.
|
||||
|
||||
|
||||
[discrete]
|
||||
==== `ConnectionPool`
|
||||
|
||||
This class is responsible for keeping in memory all the {es} Connection that you
|
||||
are using. There is a single Connection for every node. The connection pool
|
||||
handles the resurrection strategies and the updates of the pool.
|
||||
|
||||
[source,js]
|
||||
----
|
||||
const { Client, ConnectionPool } = require('@elastic/elasticsearch')
|
||||
|
||||
class MyConnectionPool extends ConnectionPool {
|
||||
markAlive (connection) {
|
||||
// your code
|
||||
super.markAlive(connection)
|
||||
}
|
||||
}
|
||||
|
||||
const client = new Client({
|
||||
ConnectionPool: MyConnectionPool,
|
||||
cloud: { id: '<cloud-id>' },
|
||||
auth: { apiKey: 'base64EncodedKey' }
|
||||
})
|
||||
----
|
||||
|
||||
|
||||
[discrete]
|
||||
==== `Connection`
|
||||
|
||||
This class represents a single node, it holds every information we have on the
|
||||
node, such as roles, id, URL, custom headers and so on. The actual HTTP request
|
||||
is performed here, this means that if you want to swap the default HTTP client
|
||||
(Node.js core), you should override the `request` method of this class.
|
||||
|
||||
[source,js]
|
||||
----
|
||||
const { Client, BaseConnection } = require('@elastic/elasticsearch')
|
||||
|
||||
class MyConnection extends BaseConnection {
|
||||
request (params, callback) {
|
||||
// your code
|
||||
}
|
||||
}
|
||||
|
||||
const client = new Client({
|
||||
Connection: MyConnection,
|
||||
cloud: { id: '<cloud-id>' },
|
||||
auth: { apiKey: 'base64EncodedKey' }
|
||||
})
|
||||
----
|
||||
|
||||
|
||||
[discrete]
|
||||
==== `Serializer`
|
||||
|
||||
This class is responsible for the serialization of every request, it offers the
|
||||
following methods:
|
||||
|
||||
* `serialize(object: any): string;` serializes request objects.
|
||||
* `deserialize(json: string): any;` deserializes response strings.
|
||||
* `ndserialize(array: any[]): string;` serializes bulk request objects.
|
||||
* `qserialize(object: any): string;` serializes request query parameters.
|
||||
|
||||
[source,js]
|
||||
----
|
||||
const { Client, Serializer } = require('@elastic/elasticsearch')
|
||||
|
||||
class MySerializer extends Serializer {
|
||||
serialize (object) {
|
||||
// your code
|
||||
}
|
||||
}
|
||||
|
||||
const client = new Client({
|
||||
Serializer: MySerializer,
|
||||
cloud: { id: '<cloud-id>' },
|
||||
auth: { apiKey: 'base64EncodedKey' }
|
||||
})
|
||||
----
|
||||
|
||||
[discrete]
|
||||
==== Migrate to v8
|
||||
|
||||
The Node.js client can be configured to emit an HTTP header
|
||||
`Accept: application/vnd.elasticsearch+json; compatible-with=7`
|
||||
which signals to Elasticsearch that the client is requesting
|
||||
`7.x` version of request and response bodies. This allows for
|
||||
upgrading from 7.x to 8.x version of Elasticsearch without upgrading
|
||||
everything at once. Elasticsearch should be upgraded first after
|
||||
the compatibility header is configured and clients should be upgraded
|
||||
second.
|
||||
To enable to setting, configure the environment variable
|
||||
`ELASTIC_CLIENT_APIVERSIONING` to `true`.
|
||||
@ -1,270 +0,0 @@
|
||||
[[basic-config]]
|
||||
=== Basic configuration
|
||||
|
||||
This page shows you the possible basic configuration options that the clients
|
||||
offers.
|
||||
|
||||
|
||||
[source,js]
|
||||
----
|
||||
const { Client } = require('@elastic/elasticsearch')
|
||||
|
||||
const client = new Client({
|
||||
cloud: { id: '<cloud-id>' },
|
||||
auth: { apiKey: 'base64EncodedKey' },
|
||||
maxRetries: 5,
|
||||
requestTimeout: 60000,
|
||||
sniffOnStart: true
|
||||
})
|
||||
----
|
||||
|
||||
|
||||
[cols=2*]
|
||||
|===
|
||||
|`node` or `nodes`
|
||||
a|The Elasticsearch endpoint to use. +
|
||||
It can be a single string or an array of strings:
|
||||
[source,js]
|
||||
----
|
||||
node: 'http://localhost:9200'
|
||||
----
|
||||
Or it can be an object (or an array of objects) that represents the node:
|
||||
[source,js]
|
||||
----
|
||||
node: {
|
||||
url: new URL('http://localhost:9200'),
|
||||
tls: 'tls options',
|
||||
agent: 'http agent options',
|
||||
id: 'custom node id',
|
||||
headers: { 'custom': 'headers' }
|
||||
roles: {
|
||||
master: true,
|
||||
data: true,
|
||||
ingest: true,
|
||||
ml: false
|
||||
}
|
||||
}
|
||||
----
|
||||
|
||||
|`auth`
|
||||
a|Your authentication data. You can use both basic authentication and
|
||||
{ref}/security-api-create-api-key.html[ApiKey]. +
|
||||
See <<authentication,Authentication>> for more details. +
|
||||
_Default:_ `null`
|
||||
|
||||
Basic authentication:
|
||||
[source,js]
|
||||
----
|
||||
auth: {
|
||||
username: 'elastic',
|
||||
password: 'changeme'
|
||||
}
|
||||
----
|
||||
{ref}/security-api-create-api-key.html[ApiKey] authentication:
|
||||
[source,js]
|
||||
----
|
||||
auth: {
|
||||
apiKey: 'base64EncodedKey'
|
||||
}
|
||||
----
|
||||
Bearer authentication, useful for https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-create-service-token.html[service account tokens]. Be aware that it does not handle automatic token refresh:
|
||||
[source,js]
|
||||
----
|
||||
auth: {
|
||||
bearer: 'token'
|
||||
}
|
||||
----
|
||||
|
||||
|
||||
|`maxRetries`
|
||||
|`number` - Max number of retries for each request. +
|
||||
_Default:_ `3`
|
||||
|
||||
|`requestTimeout`
|
||||
|`number` - Max request timeout in milliseconds for each request. +
|
||||
_Default:_ `30000`
|
||||
|
||||
|`pingTimeout`
|
||||
|`number` - Max ping request timeout in milliseconds for each request. +
|
||||
_Default:_ `3000`
|
||||
|
||||
|`sniffInterval`
|
||||
|`number, boolean` - Perform a sniff operation every `n` milliseconds. Sniffing might not be the best solution for you, take a look https://www.elastic.co/blog/elasticsearch-sniffing-best-practices-what-when-why-how[here] to know more. +
|
||||
_Default:_ `false`
|
||||
|
||||
|`sniffOnStart`
|
||||
|`boolean` - Perform a sniff once the client is started. Sniffing might not be the best solution for you, take a look https://www.elastic.co/blog/elasticsearch-sniffing-best-practices-what-when-why-how[here] to know more. +
|
||||
_Default:_ `false`
|
||||
|
||||
|`sniffEndpoint`
|
||||
|`string` - Endpoint to ping during a sniff. +
|
||||
_Default:_ `'_nodes/_all/http'`
|
||||
|
||||
|`sniffOnConnectionFault`
|
||||
|`boolean` - Perform a sniff on connection fault. Sniffing might not be the best solution for you, take a look https://www.elastic.co/blog/elasticsearch-sniffing-best-practices-what-when-why-how[here] to know more. +
|
||||
_Default:_ `false`
|
||||
|
||||
|`resurrectStrategy`
|
||||
|`string` - Configure the node resurrection strategy. +
|
||||
_Options:_ `'ping'`, `'optimistic'`, `'none'` +
|
||||
_Default:_ `'ping'`
|
||||
|
||||
|`suggestCompression`
|
||||
|`boolean` - Adds `accept-encoding` header to every request. +
|
||||
_Default:_ `false`
|
||||
|
||||
|`compression`
|
||||
|`string, boolean` - Enables gzip request body compression. +
|
||||
_Options:_ `'gzip'`, `false` +
|
||||
_Default:_ `false`
|
||||
|
||||
|`tls`
|
||||
|`http.SecureContextOptions` - tls https://nodejs.org/api/tls.html[configuraton]. +
|
||||
_Default:_ `null`
|
||||
|
||||
|`proxy`
|
||||
a|`string, URL` - If you are using an http(s) proxy, you can put its url here.
|
||||
The client will automatically handle the connection to it. +
|
||||
_Default:_ `null`
|
||||
[source,js]
|
||||
----
|
||||
const client = new Client({
|
||||
node: 'http://localhost:9200',
|
||||
proxy: 'http://localhost:8080'
|
||||
})
|
||||
|
||||
// Proxy with basic authentication
|
||||
const client = new Client({
|
||||
node: 'http://localhost:9200',
|
||||
proxy: 'http://user:pwd@localhost:8080'
|
||||
})
|
||||
----
|
||||
|
||||
|`agent`
|
||||
a|`http.AgentOptions, function` - http agent https://nodejs.org/api/http.html#http_new_agent_options[options],
|
||||
or a function that returns an actual http agent instance. If you want to disable the http agent use entirely
|
||||
(and disable the `keep-alive` feature), set the agent to `false`. +
|
||||
_Default:_ `null`
|
||||
[source,js]
|
||||
----
|
||||
const client = new Client({
|
||||
node: 'http://localhost:9200',
|
||||
agent: { agent: 'options' }
|
||||
})
|
||||
|
||||
const client = new Client({
|
||||
node: 'http://localhost:9200',
|
||||
// the function takes as parameter the option
|
||||
// object passed to the Connection constructor
|
||||
agent: (opts) => new CustomAgent()
|
||||
})
|
||||
|
||||
const client = new Client({
|
||||
node: 'http://localhost:9200',
|
||||
// Disable agent and keep-alive
|
||||
agent: false
|
||||
})
|
||||
----
|
||||
|
||||
|`nodeFilter`
|
||||
a|`function` - Filters which node not to use for a request. +
|
||||
_Default:_
|
||||
[source,js]
|
||||
----
|
||||
function defaultNodeFilter (node) {
|
||||
// avoid master only nodes
|
||||
if (node.roles.master === true &&
|
||||
node.roles.data === false &&
|
||||
node.roles.ingest === false) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
----
|
||||
|
||||
|`nodeSelector`
|
||||
a|`function` - custom selection strategy. +
|
||||
_Options:_ `'round-robin'`, `'random'`, custom function +
|
||||
_Default:_ `'round-robin'` +
|
||||
_Custom function example:_
|
||||
[source,js]
|
||||
----
|
||||
function nodeSelector (connections) {
|
||||
const index = calculateIndex()
|
||||
return connections[index]
|
||||
}
|
||||
----
|
||||
|
||||
|`generateRequestId`
|
||||
a|`function` - function to generate the request id for every request, it takes
|
||||
two parameters, the request parameters and options. +
|
||||
By default it generates an incremental integer for every request. +
|
||||
_Custom function example:_
|
||||
[source,js]
|
||||
----
|
||||
function generateRequestId (params, options) {
|
||||
// your id generation logic
|
||||
// must be syncronous
|
||||
return 'id'
|
||||
}
|
||||
----
|
||||
|
||||
|`name`
|
||||
|`string, symbol` - The name to identify the client instance in the events. +
|
||||
_Default:_ `elasticsearch-js`
|
||||
|
||||
|`opaqueIdPrefix`
|
||||
|`string` - A string that will be use to prefix any `X-Opaque-Id` header. +
|
||||
See https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/observability.html#_x-opaque-id_support[`X-Opaque-Id` support] for more details. +
|
||||
_Default:_ `null`
|
||||
|
||||
|`headers`
|
||||
|`object` - A set of custom headers to send in every request. +
|
||||
_Default:_ `{}`
|
||||
|
||||
|`context`
|
||||
|`object` - A custom object that you can use for observability in your events.
|
||||
It will be merged with the API level context option. +
|
||||
_Default:_ `null`
|
||||
|
||||
|`enableMetaHeader`
|
||||
|`boolean` - If true, adds an header named `'x-elastic-client-meta'`, containing some minimal telemetry data,
|
||||
such as the client and platform version. +
|
||||
_Default:_ `true`
|
||||
|
||||
|`cloud`
|
||||
a|`object` - Custom configuration for connecting to
|
||||
https://cloud.elastic.co[Elastic Cloud]. See https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/auth-reference.html[Authentication]
|
||||
for more details. +
|
||||
_Default:_ `null` +
|
||||
_Cloud configuration example:_
|
||||
[source,js]
|
||||
----
|
||||
const client = new Client({
|
||||
cloud: {
|
||||
id: '<cloud-id>'
|
||||
},
|
||||
auth: {
|
||||
username: 'elastic',
|
||||
password: 'changeme'
|
||||
}
|
||||
})
|
||||
----
|
||||
|
||||
|`disablePrototypePoisoningProtection`
|
||||
|`boolean`, `'proto'`, `'constructor'` - By the default the client will protect you against prototype poisoning attacks. Read https://web.archive.org/web/20200319091159/https://hueniverse.com/square-brackets-are-the-enemy-ff5b9fd8a3e8?gi=184a27ee2a08[this article] to learn more. If needed you can disable prototype poisoning protection entirely or one of the two checks. Read the `secure-json-parse` https://github.com/fastify/secure-json-parse[documentation] to learn more. +
|
||||
_Default:_ `false`
|
||||
|
||||
|`caFingerprint`
|
||||
|`string` - If configured, verify that the fingerprint of the CA certificate that has signed the certificate of the server matches the supplied fingerprint. Only accepts SHA256 digest fingerprints. +
|
||||
_Default:_ `null`
|
||||
|
||||
|`maxResponseSize`
|
||||
|`number` - When configured, it verifies that the uncompressed response size is lower than the configured number, if it's higher it will abort the request. It cannot be higher than buffer.constants.MAX_STRING_LENTGH +
|
||||
_Default:_ `null`
|
||||
|
||||
|`maxCompressedResponseSize`
|
||||
|`number` - When configured, it verifies that the compressed response size is lower than the configured number, if it's higher it will abort the request. It cannot be higher than buffer.constants.MAX_LENTGH +
|
||||
_Default:_ `null`
|
||||
|
||||
|===
|
||||
@ -1,573 +0,0 @@
|
||||
[[changelog-client]]
|
||||
== Release notes
|
||||
|
||||
[discrete]
|
||||
=== 8.10.0
|
||||
|
||||
[discrete]
|
||||
=== Features
|
||||
|
||||
[discrete]
|
||||
===== Support for Elasticsearch `v8.10.0`
|
||||
|
||||
You can find all the API changes
|
||||
https://www.elastic.co/guide/en/elasticsearch/reference/8.10/release-notes-8.10.0.html[here].
|
||||
|
||||
[discrete]
|
||||
=== 8.9.1
|
||||
|
||||
[discrete]
|
||||
==== Fixes
|
||||
|
||||
[discrete]
|
||||
===== Upgrade Transport https://github.com/elastic/elasticsearch-js/pull/1968[#1968]
|
||||
|
||||
Upgrades `@elastic/transport` to the latest patch release to fix https://github.com/elastic/elastic-transport-js/pull/69[a bug] that could cause the process to exit when handling malformed `HEAD` requests.
|
||||
|
||||
[discrete]
|
||||
=== 8.9.0
|
||||
|
||||
[discrete]
|
||||
==== Features
|
||||
|
||||
[discrete]
|
||||
===== Support for Elasticsearch `v8.9.0`
|
||||
|
||||
You can find all the API changes
|
||||
https://www.elastic.co/guide/en/elasticsearch/reference/8.9/release-notes-8.9.0.html[here].
|
||||
|
||||
[discrete]
|
||||
===== Allow document to be overwritten in `onDocument` iteratee of bulk helper https://github.com/elastic/elasticsearch-js/pull/1732[#1732]
|
||||
|
||||
In the https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/client-helpers.html#bulk-helper[bulk helper], documents could not be modified before being sent to Elasticsearch. It is now possible to https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/client-helpers.html#_modifying_a_document_before_operation[modify a document] before sending it.
|
||||
|
||||
[discrete]
|
||||
==== Fixes
|
||||
|
||||
[discrete]
|
||||
===== Updated `user-agent` header https://github.com/elastic/elasticsearch-js/pull/1954[#1954]
|
||||
|
||||
The `user-agent` header the client used to connect to Elasticsearch was using a non-standard format that has been improved.
|
||||
|
||||
[discrete]
|
||||
=== 8.8.1
|
||||
|
||||
[discrete]
|
||||
==== Features
|
||||
|
||||
[discrete]
|
||||
===== Support for Elasticsearch `v8.8.1`
|
||||
|
||||
You can find all the API changes
|
||||
https://www.elastic.co/guide/en/elasticsearch/reference/8.8/release-notes-8.8.1.html[here].
|
||||
|
||||
[discrete]
|
||||
==== Fixes
|
||||
|
||||
[discrete]
|
||||
===== Fix index drift bug in bulk helper https://github.com/elastic/elasticsearch-js/pull/1759[#1759]
|
||||
|
||||
Fixes a bug in the bulk helper that would cause `onDrop` to send back the wrong JSON document or error on a nonexistent document when an error occurred on a bulk HTTP request that contained a `delete` action.
|
||||
|
||||
[discrete]
|
||||
===== Fix a memory leak caused by an outdated version of Undici https://github.com/elastic/elasticsearch-js/pull/1902[#1902]
|
||||
|
||||
Undici 5.5.1, used by https://github.com/elastic/elastic-transport-js[elastic-transport-js], could create a memory leak when a high volume of requests created too many HTTP `abort` listeners. Upgrading Undici to 5.22.1 removed the memory leak.
|
||||
|
||||
[discrete]
|
||||
=== 8.8.0
|
||||
|
||||
[discrete]
|
||||
==== Features
|
||||
|
||||
[discrete]
|
||||
===== Support for Elasticsearch `v8.8.0`
|
||||
|
||||
You can find all the API changes
|
||||
https://www.elastic.co/guide/en/elasticsearch/reference/8.8/release-notes-8.8.0.html[here].
|
||||
|
||||
[discrete]
|
||||
==== Fixes
|
||||
|
||||
[discrete]
|
||||
===== Fix type declarations for legacy types with a body key https://github.com/elastic/elasticsearch-js/pull/1784[#1784]
|
||||
|
||||
Prior releases contained a bug where type declarations for legacy types that include a `body` key were not actually importing the type that includes the `body` key.
|
||||
|
||||
[discrete]
|
||||
=== 8.7.0
|
||||
|
||||
[discrete]
|
||||
===== Support for Elasticsearch `v8.7.0`
|
||||
|
||||
You can find all the API changes
|
||||
https://www.elastic.co/guide/en/elasticsearch/reference/8.7/release-notes-8.7.0.html[here].
|
||||
|
||||
[discrete]
|
||||
=== 8.6.0
|
||||
|
||||
[discrete]
|
||||
===== Bump @elastic/transport to 8.3.1+ https://github.com/elastic/elasticsearch-js/pull/1802[#1802]
|
||||
|
||||
The `@elastic/transport` dependency has been bumped to `~8.3.1` to ensure
|
||||
fixes to the `maxResponseSize` option are available in the client.
|
||||
|
||||
[discrete]
|
||||
===== Support for Elasticsearch `v8.6.0`
|
||||
|
||||
You can find all the API changes
|
||||
https://www.elastic.co/guide/en/elasticsearch/reference/8.6/release-notes-8.6.0.html[here].
|
||||
|
||||
[discrete]
|
||||
=== 8.5.0
|
||||
|
||||
[discrete]
|
||||
===== Support for Elasticsearch `v8.5.0`
|
||||
|
||||
You can find all the API changes
|
||||
https://www.elastic.co/guide/en/elasticsearch/reference/8.5/release-notes-8.5.0.html[here].
|
||||
|
||||
[discrete]
|
||||
=== 8.4.0
|
||||
|
||||
[discrete]
|
||||
===== Support for Elasticsearch `v8.4.0`
|
||||
|
||||
You can find all the API changes
|
||||
https://www.elastic.co/guide/en/elasticsearch/reference/8.4/release-notes-8.4.0.html[here].
|
||||
|
||||
[discrete]
|
||||
=== 8.2.1
|
||||
|
||||
[discrete]
|
||||
==== Fixes
|
||||
|
||||
[discrete]
|
||||
===== Support for Elasticsearch `v8.2.1`
|
||||
|
||||
You can find all the API changes
|
||||
https://www.elastic.co/guide/en/elasticsearch/reference/8.2/release-notes-8.2.1.html[here].
|
||||
|
||||
[discrete]
|
||||
===== Fix ndjson APIs https://github.com/elastic/elasticsearch-js/pull/1688[#1688]
|
||||
|
||||
The previous release contained a bug that broken ndjson APIs.
|
||||
We have released `v8.2.0-patch.1` to address this.
|
||||
This fix is the same as the one we have released and we strongly recommend upgrading to this version.
|
||||
|
||||
[discrete]
|
||||
===== Fix node shutdown apis https://github.com/elastic/elasticsearch-js/pull/1697[#1697]
|
||||
|
||||
The shutdown APIs wheren't complete, this fix completes them.
|
||||
|
||||
[discrete]
|
||||
==== Types: move query keys to body https://github.com/elastic/elasticsearch-js/pull/1693[#1693]
|
||||
|
||||
The types definitions where wrongly representing the types of fields present in both query and body.
|
||||
|
||||
[discrete]
|
||||
=== 8.2.0
|
||||
|
||||
[discrete]
|
||||
==== Breaking changes
|
||||
|
||||
[discrete]
|
||||
===== Drop Node.js v12 https://github.com/elastic/elasticsearch-js/pull/1670[#1670]
|
||||
|
||||
According to our https://github.com/elastic/elasticsearch-js#nodejs-support[Node.js support matrix].
|
||||
|
||||
[discrete]
|
||||
==== Features
|
||||
|
||||
[discrete]
|
||||
===== Support for Elasticsearch `v8.2`
|
||||
|
||||
You can find all the API changes
|
||||
https://www.elastic.co/guide/en/elasticsearch/reference/8.2/release-notes-8.2.0.html[here].
|
||||
|
||||
[discrete]
|
||||
===== More lenient parameter checks https://github.com/elastic/elasticsearch-js/pull/1662[#1662]
|
||||
|
||||
When creating a new client, an `undefined` `caFingerprint` no longer trigger an error for a http connection.
|
||||
|
||||
[discrete]
|
||||
===== Update TypeScript docs and export estypes https://github.com/elastic/elasticsearch-js/pull/1675[#1675]
|
||||
|
||||
You can import the full TypeScript requests & responses definitions as it follows:
|
||||
[source,ts]
|
||||
----
|
||||
import { estypes } from '@elastic/elasticsearch'
|
||||
----
|
||||
|
||||
If you need the legacy definitions with the body, you can do the following:
|
||||
|
||||
[source,ts]
|
||||
----
|
||||
import { estypesWithBody } from '@elastic/elasticsearch'
|
||||
----
|
||||
|
||||
[discrete]
|
||||
==== Fixes
|
||||
|
||||
[discrete]
|
||||
===== Updated hpagent to the latest version https://github.com/elastic/elastic-transport-js/pull/49[transport/#49]
|
||||
|
||||
You can fing the related changes https://github.com/delvedor/hpagent/releases/tag/v1.0.0[here].
|
||||
|
||||
[discrete]
|
||||
=== 8.1.0
|
||||
|
||||
[discrete]
|
||||
==== Features
|
||||
|
||||
[discrete]
|
||||
===== Support for Elasticsearch `v8.1`
|
||||
|
||||
You can find all the API changes
|
||||
https://www.elastic.co/guide/en/elasticsearch/reference/8.1/release-notes-8.1.0.html[here].
|
||||
|
||||
[discrete]
|
||||
===== Export SniffingTransport https://github.com/elastic/elasticsearch-js/pull/1653[#1653]
|
||||
|
||||
Now the client exports the SniffingTransport class.
|
||||
|
||||
[discrete]
|
||||
==== Fixes
|
||||
|
||||
[discrete]
|
||||
===== Fix onFlushTimeout timer not being cleared when upstream errors https://github.com/elastic/elasticsearch-js/pull/1616[#1616]
|
||||
|
||||
Fixes a memory leak caused by an error in the upstream dataset of the bulk helper.
|
||||
|
||||
[discrete]
|
||||
===== Cleanup abort listener https://github.com/elastic/elastic-transport-js/pull/42[transport/#42]
|
||||
|
||||
The legacy http client was not cleaning up the abort listener, which could cause a memory leak.
|
||||
|
||||
[discrete]
|
||||
===== Improve undici performances https://github.com/elastic/elastic-transport-js/pull/41[transport/#41]
|
||||
|
||||
Improve the stream body collection and keep alive timeout.
|
||||
|
||||
[discrete]
|
||||
=== 8.0.0
|
||||
|
||||
[discrete]
|
||||
==== Features
|
||||
|
||||
[discrete]
|
||||
===== Support for Elasticsearch `v8.0`
|
||||
|
||||
You can find all the API changes
|
||||
https://www.elastic.co/guide/en/elasticsearch/reference/8.0/release-notes-8.0.0.html[here].
|
||||
|
||||
[discrete]
|
||||
===== Drop old typescript definitions
|
||||
|
||||
*Breaking: Yes* | *Migration effort: Medium*
|
||||
|
||||
The current TypeScript definitions will be removed from the client, and the new definitions, which contain request and response definitions as well will be shipped by default.
|
||||
|
||||
[discrete]
|
||||
===== Drop callback-style API
|
||||
|
||||
*Breaking: Yes* | *Migration effort: Large*
|
||||
|
||||
Maintaining both API styles is not a problem per se, but it makes error handling more convoluted due to async stack traces.
|
||||
Moving to a full-promise API will solve this issue.
|
||||
|
||||
[source,js]
|
||||
----
|
||||
// callback-style api
|
||||
client.search({ params }, { options }, (err, result) => {
|
||||
console.log(err || result)
|
||||
})
|
||||
|
||||
// promise-style api
|
||||
client.search({ params }, { options })
|
||||
.then(console.log)
|
||||
.catch(console.log)
|
||||
|
||||
// async-style (sugar syntax on top of promises)
|
||||
const response = await client.search({ params }, { options })
|
||||
console.log(response)
|
||||
----
|
||||
|
||||
If you are already using the promise-style API, this won't be a breaking change for you.
|
||||
|
||||
[discrete]
|
||||
===== Remove the current abort API and use the new AbortController standard
|
||||
|
||||
*Breaking: Yes* | *Migration effort: Small*
|
||||
|
||||
The old abort API makes sense for callbacks but it's annoying to use with promises
|
||||
|
||||
[source,js]
|
||||
----
|
||||
// callback-style api
|
||||
const request = client.search({ params }, { options }, (err, result) => {
|
||||
console.log(err) // RequestAbortedError
|
||||
})
|
||||
|
||||
request.abort()
|
||||
|
||||
// promise-style api
|
||||
const promise = client.search({ params }, { options })
|
||||
|
||||
promise
|
||||
.then(console.log)
|
||||
.catch(console.log) // RequestAbortedError
|
||||
|
||||
promise.abort()
|
||||
----
|
||||
|
||||
Node v12 has added the standard https://nodejs.org/api/globals.html#globals_class_abortcontroller[`AbortController`] API which is designed to work well with both callbacks and promises.
|
||||
[source,js]
|
||||
----
|
||||
const ac = new AbortController()
|
||||
client.search({ params }, { signal: ac.signal })
|
||||
.then(console.log)
|
||||
.catch(console.log) // RequestAbortedError
|
||||
|
||||
ac.abort()
|
||||
----
|
||||
|
||||
[discrete]
|
||||
===== Remove the body key from the request
|
||||
|
||||
*Breaking: Yes* | *Migration effort: Small*
|
||||
|
||||
Thanks to the new types we are developing now we know exactly where a parameter should go.
|
||||
The client API leaks HTTP-related notions in many places, and removing them would definitely improve the DX.
|
||||
|
||||
This could be a rather big breaking change, so a double solution could be used during the 8.x lifecycle. (accepting body keys without them being wrapped in the body as well as the current solution).
|
||||
|
||||
[source,js]
|
||||
----
|
||||
// from
|
||||
const response = await client.search({
|
||||
index: 'test',
|
||||
body: {
|
||||
query: {
|
||||
match_all: {}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
// to
|
||||
const response = await client.search({
|
||||
index: 'test',
|
||||
query: {
|
||||
match_all: {}
|
||||
}
|
||||
})
|
||||
----
|
||||
|
||||
[discrete]
|
||||
===== Migrate to new separate transport
|
||||
|
||||
*Breaking: Yes* | *Migration effort: Small to none*
|
||||
|
||||
The separated transport has been rewritten in TypeScript and has already dropped the callback style API.
|
||||
Given that now is separated, most of the Elasticsearch specific concepts have been removed, and the client will likely need to extend parts of it for reintroducing them.
|
||||
If you weren't extending the internals of the client, this won't be a breaking change for you.
|
||||
|
||||
[discrete]
|
||||
===== The returned value of API calls is the body and not the HTTP related keys
|
||||
|
||||
*Breaking: Yes* | *Migration effort: Small*
|
||||
|
||||
The client API leaks HTTP-related notions in many places, and removing them would definitely improve the DX.
|
||||
The client will expose a new request-specific option to still get the full response details.
|
||||
|
||||
[source,js]
|
||||
----
|
||||
// from
|
||||
const response = await client.search({
|
||||
index: 'test',
|
||||
body: {
|
||||
query: {
|
||||
match_all: {}
|
||||
}
|
||||
}
|
||||
})
|
||||
console.log(response) // { body: SearchResponse, statusCode: number, headers: object, warnings: array }
|
||||
|
||||
// to
|
||||
const response = await client.search({
|
||||
index: 'test',
|
||||
query: {
|
||||
match_all: {}
|
||||
}
|
||||
})
|
||||
console.log(response) // SearchResponse
|
||||
|
||||
// with a bit of TypeScript and JavaScript magic...
|
||||
const response = await client.search({
|
||||
index: 'test',
|
||||
query: {
|
||||
match_all: {}
|
||||
}
|
||||
}, {
|
||||
meta: true
|
||||
})
|
||||
console.log(response) // { body: SearchResponse, statusCode: number, headers: object, warnings: array }
|
||||
----
|
||||
|
||||
[discrete]
|
||||
===== Use a weighted connection pool
|
||||
|
||||
*Breaking: Yes* | *Migration effort: Small to none*
|
||||
|
||||
Move from the current cluster connection pool to a weight-based implementation.
|
||||
This new implementation offers better performances and runs less code in the background, the old connection pool can still be used.
|
||||
If you weren't extending the internals of the client, this won't be a breaking change for you.
|
||||
|
||||
[discrete]
|
||||
===== Migrate to the "undici" http client
|
||||
|
||||
*Breaking: Yes* | *Migration effort: Small to none*
|
||||
|
||||
By default, the HTTP client will no longer be the default Node.js HTTP client, but https://github.com/nodejs/undici[undici] instead.
|
||||
Undici is a brand new HTTP client written from scratch, it offers vastly improved performances and has better support for promises.
|
||||
Furthermore, it offers comprehensive and predictable error handling. The old HTTP client can still be used.
|
||||
If you weren't extending the internals of the client, this won't be a breaking change for you.
|
||||
|
||||
[discrete]
|
||||
===== Drop support for old camelCased keys
|
||||
|
||||
*Breaking: Yes* | *Migration effort: Medium*
|
||||
|
||||
Currently, every path or query parameter could be expressed in both `snake_case` and `camelCase`. Internally the client will convert everything to `snake_case`.
|
||||
This was done in an effort to reduce the friction of migrating from the legacy to the new client, but now it no longer makes sense.
|
||||
If you are already using `snake_case` keys, this won't be a breaking change for you.
|
||||
|
||||
[discrete]
|
||||
===== Rename `ssl` option to `tls`
|
||||
|
||||
*Breaking: Yes* | *Migration effort: Small*
|
||||
|
||||
People usually refers to this as `tls`, furthermore, internally we use the tls API and Node.js refers to it as tls everywhere.
|
||||
[source,js]
|
||||
----
|
||||
// before
|
||||
const client = new Client({
|
||||
node: 'https://localhost:9200',
|
||||
ssl: {
|
||||
rejectUnauthorized: false
|
||||
}
|
||||
})
|
||||
|
||||
// after
|
||||
const client = new Client({
|
||||
node: 'https://localhost:9200',
|
||||
tls: {
|
||||
rejectUnauthorized: false
|
||||
}
|
||||
})
|
||||
----
|
||||
|
||||
[discrete]
|
||||
===== Remove prototype poisoning protection
|
||||
|
||||
*Breaking: Yes* | *Migration effort: Small*
|
||||
|
||||
Prototype poisoning protection is very useful, but it can cause performances issues with big payloads.
|
||||
In v8 it will be removed, and the documentation will show how to add it back with a custom serializer.
|
||||
|
||||
[discrete]
|
||||
===== Remove client extensions API
|
||||
|
||||
*Breaking: Yes* | *Migration effort: Large*
|
||||
|
||||
Nowadays the client support the entire Elasticsearch API, and the `transport.request` method can be used if necessary. The client extensions API have no reason to exist.
|
||||
[source,js]
|
||||
----
|
||||
client.extend('utility.index', ({ makeRequest }) => {
|
||||
return function _index (params, options) {
|
||||
// your code
|
||||
}
|
||||
})
|
||||
|
||||
client.utility.index(...)
|
||||
----
|
||||
|
||||
If you weren't using client extensions, this won't be a breaking change for you.
|
||||
|
||||
[discrete]
|
||||
===== Move to TypeScript
|
||||
|
||||
*Breaking: No* | *Migration effort: None*
|
||||
|
||||
The new separated transport is already written in TypeScript, and it makes sense that the client v8 will be fully written in TypeScript as well.
|
||||
|
||||
[discrete]
|
||||
===== Move from emitter-like interface to a diagnostic method
|
||||
|
||||
*Breaking: Yes* | *Migration effort: Small*
|
||||
|
||||
Currently, the client offers a subset of methods of the `EventEmitter` class, v8 will ship with a `diagnostic` property which will be a proper event emitter.
|
||||
[source,js]
|
||||
----
|
||||
// from
|
||||
client.on('request', console.log)
|
||||
|
||||
// to
|
||||
client.diagnostic.on('request', console.log)
|
||||
----
|
||||
|
||||
[discrete]
|
||||
===== Remove username & password properties from Cloud configuration
|
||||
|
||||
*Breaking: Yes* | *Migration effort: Small*
|
||||
|
||||
The Cloud configuration does not support ApiKey and Bearer auth, while the `auth` options does.
|
||||
There is no need to keep the legacy basic auth support in the cloud configuration.
|
||||
[source,js]
|
||||
----
|
||||
// before
|
||||
const client = new Client({
|
||||
cloud: {
|
||||
id: '<cloud-id>',
|
||||
username: 'elastic',
|
||||
password: 'changeme'
|
||||
}
|
||||
})
|
||||
|
||||
// after
|
||||
const client = new Client({
|
||||
cloud: {
|
||||
id: '<cloud-id>'
|
||||
},
|
||||
auth: {
|
||||
username: 'elastic',
|
||||
password: 'changeme'
|
||||
}
|
||||
})
|
||||
----
|
||||
|
||||
If you are already passing the basic auth options in the `auth` configuration, this won't be a breaking change for you.
|
||||
|
||||
[discrete]
|
||||
===== Calling `client.close` will reject new requests
|
||||
|
||||
Once you call `client.close` every new request after that will be rejected with a `NoLivingConnectionsError`. In-flight requests will be executed normally unless an in-flight request requires a retry, in which case it will be rejected.
|
||||
|
||||
[discrete]
|
||||
===== Parameters rename
|
||||
|
||||
- `ilm.delete_lifecycle`: `policy` parameter has been renamed to `name`
|
||||
- `ilm.get_lifecycle`: `policy` parameter has been renamed to `name`
|
||||
- `ilm.put_lifecycle`: `policy` parameter has been renamed to `name`
|
||||
- `snapshot.cleanup_repository`: `repository` parameter has been renamed to `name`
|
||||
- `snapshot.create_repository`: `repository` parameter has been renamed to `name`
|
||||
- `snapshot.delete_repository`: `repository` parameter has been renamed to `name`
|
||||
- `snapshot.get_repository`: `repository` parameter has been renamed to `name`
|
||||
- `snapshot.verify_repository`: `repository` parameter has been renamed to `name`
|
||||
|
||||
[discrete]
|
||||
===== Removal of snake_cased methods
|
||||
|
||||
The v7 client provided snake_cased methods, such as `client.delete_by_query`. This is no longer supported, now only camelCased method are present.
|
||||
So `client.delete_by_query` can be accessed with `client.deleteByQuery`
|
||||
|
||||
@ -1,36 +0,0 @@
|
||||
[[child]]
|
||||
=== Creating a child client
|
||||
|
||||
There are some use cases where you may need multiple instances of the client.
|
||||
You can easily do that by calling `new Client()` as many times as you need, but
|
||||
you will lose all the benefits of using one single client, such as the long
|
||||
living connections and the connection pool handling. To avoid this problem, the
|
||||
client offers a `child` API, which returns a new client instance that shares the
|
||||
connection pool with the parent client.
|
||||
|
||||
NOTE: The event emitter is shared between the parent and the child(ren). If you
|
||||
extend the parent client, the child client will have the same extensions, while
|
||||
if the child client adds an extension, the parent client will not be extended.
|
||||
|
||||
You can pass to the `child` every client option you would pass to a normal
|
||||
client, but the connection pool specific options (`ssl`, `agent`, `pingTimeout`,
|
||||
`Connection`, and `resurrectStrategy`).
|
||||
|
||||
CAUTION: If you call `close` in any of the parent/child clients, every client
|
||||
will be closed.
|
||||
|
||||
[source,js]
|
||||
----
|
||||
const { Client } = require('@elastic/elasticsearch')
|
||||
const client = new Client({
|
||||
cloud: { id: '<cloud-id>' },
|
||||
auth: { apiKey: 'base64EncodedKey' }
|
||||
})
|
||||
const child = client.child({
|
||||
headers: { 'x-foo': 'bar' },
|
||||
requestTimeout: 1000
|
||||
})
|
||||
|
||||
client.info().then(console.log, console.log)
|
||||
child.info().then(console.log, console.log)
|
||||
----
|
||||
@ -1,11 +0,0 @@
|
||||
[[client-configuration]]
|
||||
== Configuration
|
||||
|
||||
|
||||
The client is designed to be easily configured for your needs. In the following
|
||||
section, you can see the possible options that you can use to configure it.
|
||||
|
||||
* <<basic-config>>
|
||||
* <<advanced-config>>
|
||||
* <<child>>
|
||||
* <<client-testing>>
|
||||
@ -1,704 +0,0 @@
|
||||
[[client-connecting]]
|
||||
== Connecting
|
||||
|
||||
This page contains the information you need to connect and use the Client with
|
||||
{es}.
|
||||
|
||||
**On this page**
|
||||
|
||||
* <<authentication, Authentication options>>
|
||||
* <<client-usage, Using the client>>
|
||||
* <<client-faas-env, Using the Client in a Function-as-a-Service Environment>>
|
||||
* <<client-connect-proxy, Connecting through a proxy>>
|
||||
* <<client-error-handling, Handling errors>>
|
||||
* <<keep-alive, Keep-alive connections>>
|
||||
* <<product-check, Automatic product check>>
|
||||
|
||||
[[authentication]]
|
||||
[discrete]
|
||||
=== Authentication
|
||||
|
||||
This document contains code snippets to show you how to connect to various {es}
|
||||
providers.
|
||||
|
||||
|
||||
[discrete]
|
||||
[[auth-ec]]
|
||||
==== Elastic Cloud
|
||||
|
||||
If you are using https://www.elastic.co/cloud[Elastic Cloud], the client offers
|
||||
an easy way to connect to it via the `cloud` option. You must pass the Cloud ID
|
||||
that you can find in the cloud console, then your username and password inside
|
||||
the `auth` option.
|
||||
|
||||
NOTE: When connecting to Elastic Cloud, the client will automatically enable
|
||||
both request and response compression by default, since it yields significant
|
||||
throughput improvements. Moreover, the client will also set the tls option
|
||||
`secureProtocol` to `TLSv1_2_method` unless specified otherwise. You can still
|
||||
override this option by configuring them.
|
||||
|
||||
IMPORTANT: Do not enable sniffing when using Elastic Cloud, since the nodes are
|
||||
behind a load balancer, Elastic Cloud will take care of everything for you.
|
||||
Take a look https://www.elastic.co/blog/elasticsearch-sniffing-best-practices-what-when-why-how[here]
|
||||
to know more.
|
||||
|
||||
[source,js]
|
||||
----
|
||||
const { Client } = require('@elastic/elasticsearch')
|
||||
const client = new Client({
|
||||
cloud: {
|
||||
id: '<cloud-id>'
|
||||
},
|
||||
auth: {
|
||||
username: 'elastic',
|
||||
password: 'changeme'
|
||||
}
|
||||
})
|
||||
----
|
||||
|
||||
[discrete]
|
||||
[[connect-self-managed-new]]
|
||||
=== Connecting to a self-managed cluster
|
||||
|
||||
By default {es} will start with security features like authentication and TLS
|
||||
enabled. To connect to the {es} cluster you'll need to configure the Node.js {es}
|
||||
client to use HTTPS with the generated CA certificate in order to make requests
|
||||
successfully.
|
||||
|
||||
If you're just getting started with {es} we recommend reading the documentation
|
||||
on https://www.elastic.co/guide/en/elasticsearch/reference/current/settings.html[configuring]
|
||||
and
|
||||
https://www.elastic.co/guide/en/elasticsearch/reference/current/starting-elasticsearch.html[starting {es}]
|
||||
to ensure your cluster is running as expected.
|
||||
|
||||
When you start {es} for the first time you'll see a distinct block like the one
|
||||
below in the output from {es} (you may have to scroll up if it's been a while):
|
||||
|
||||
[source,sh]
|
||||
----
|
||||
|
||||
-> Elasticsearch security features have been automatically configured!
|
||||
-> Authentication is enabled and cluster connections are encrypted.
|
||||
|
||||
-> Password for the elastic user (reset with `bin/elasticsearch-reset-password -u elastic`):
|
||||
lhQpLELkjkrawaBoaz0Q
|
||||
|
||||
-> HTTP CA certificate SHA-256 fingerprint:
|
||||
a52dd93511e8c6045e21f16654b77c9ee0f34aea26d9f40320b531c474676228
|
||||
...
|
||||
|
||||
----
|
||||
|
||||
Depending on the circumstances there are two options for verifying the HTTPS
|
||||
connection, either verifying with the CA certificate itself or via the HTTP CA
|
||||
certificate fingerprint.
|
||||
|
||||
[discrete]
|
||||
[[auth-tls]]
|
||||
==== TLS configuration
|
||||
|
||||
The generated root CA certificate can be found in the `certs` directory in your
|
||||
{es} config location (`$ES_CONF_PATH/certs/http_ca.crt`). If you're running {es}
|
||||
in Docker there is
|
||||
https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html[additional documentation for retrieving the CA certificate].
|
||||
|
||||
Without any additional configuration you can specify `https://` node urls, and
|
||||
the certificates used to sign these requests will be verified. To turn off
|
||||
certificate verification, you must specify an `tls` object in the top level
|
||||
config and set `rejectUnauthorized: false`. The default `tls` values are the
|
||||
same that Node.js's https://nodejs.org/api/tls.html#tls_tls_connect_options_callback[`tls.connect()`]
|
||||
uses.
|
||||
|
||||
[source,js]
|
||||
----
|
||||
const { Client } = require('@elastic/elasticsearch')
|
||||
const client = new Client({
|
||||
node: 'https://localhost:9200',
|
||||
auth: {
|
||||
username: 'elastic',
|
||||
password: 'changeme'
|
||||
},
|
||||
tls: {
|
||||
ca: fs.readFileSync('./http_ca.crt'),
|
||||
rejectUnauthorized: false
|
||||
}
|
||||
})
|
||||
----
|
||||
|
||||
[discrete]
|
||||
[[auth-ca-fingerprint]]
|
||||
==== CA fingerprint
|
||||
|
||||
You can configure the client to only trust certificates that are signed by a specific CA certificate
|
||||
(CA certificate pinning) by providing a `caFingerprint` option.
|
||||
This will verify that the fingerprint of the CA certificate that has signed
|
||||
the certificate of the server matches the supplied value.
|
||||
You must configure a SHA256 digest.
|
||||
|
||||
[source,js]
|
||||
----
|
||||
const { Client } = require('@elastic/elasticsearch')
|
||||
const client = new Client({
|
||||
node: 'https://example.com'
|
||||
auth: { ... },
|
||||
// the fingerprint (SHA256) of the CA certificate that is used to sign
|
||||
// the certificate that the Elasticsearch node presents for TLS.
|
||||
caFingerprint: '20:0D:CA:FA:76:...',
|
||||
tls: {
|
||||
// might be required if it's a self-signed certificate
|
||||
rejectUnauthorized: false
|
||||
}
|
||||
})
|
||||
----
|
||||
|
||||
The certificate fingerprint can be calculated using `openssl x509` with the
|
||||
certificate file:
|
||||
|
||||
[source,sh]
|
||||
----
|
||||
openssl x509 -fingerprint -sha256 -noout -in /path/to/http_ca.crt
|
||||
----
|
||||
|
||||
If you don't have access to the generated CA file from {es} you can use the
|
||||
following script to output the root CA fingerprint of the {es} instance with
|
||||
`openssl s_client`:
|
||||
|
||||
[source,sh]
|
||||
----
|
||||
# Replace the values of 'localhost' and '9200' to the
|
||||
# corresponding host and port values for the cluster.
|
||||
openssl s_client -connect localhost:9200 -servername localhost -showcerts </dev/null 2>/dev/null \
|
||||
| openssl x509 -fingerprint -sha256 -noout -in /dev/stdin
|
||||
----
|
||||
|
||||
The output of `openssl x509` will look something like this:
|
||||
|
||||
[source,sh]
|
||||
----
|
||||
SHA256 Fingerprint=A5:2D:D9:35:11:E8:C6:04:5E:21:F1:66:54:B7:7C:9E:E0:F3:4A:EA:26:D9:F4:03:20:B5:31:C4:74:67:62:28
|
||||
----
|
||||
|
||||
|
||||
[discrete]
|
||||
[[connect-no-security]]
|
||||
=== Connecting without security enabled
|
||||
|
||||
WARNING: Running {es} without security enabled is not recommended.
|
||||
|
||||
If your cluster is configured with
|
||||
https://www.elastic.co/guide/en/elasticsearch/reference/current/security-settings.html[security explicitly disabled]
|
||||
then you can connect via HTTP:
|
||||
|
||||
[source,js]
|
||||
----
|
||||
const { Client } = require('@elastic/elasticsearch')
|
||||
const client = new Client({
|
||||
node: 'http://example.com'
|
||||
})
|
||||
----
|
||||
|
||||
[discrete]
|
||||
[[auth-strategies]]
|
||||
=== Authentication strategies
|
||||
|
||||
Following you can find all the supported authentication strategies.
|
||||
|
||||
[discrete]
|
||||
[[auth-apikey]]
|
||||
==== ApiKey authentication
|
||||
|
||||
You can use the
|
||||
{ref-7x}/security-api-create-api-key.html[ApiKey]
|
||||
authentication by passing the `apiKey` parameter via the `auth` option. The
|
||||
`apiKey` parameter can be either a base64 encoded string or an object with the
|
||||
values that you can obtain from the
|
||||
{ref-7x}/security-api-create-api-key.html[create api key endpoint].
|
||||
|
||||
NOTE: If you provide both basic authentication credentials and the ApiKey
|
||||
configuration, the ApiKey takes precedence.
|
||||
|
||||
[source,js]
|
||||
----
|
||||
const { Client } = require('@elastic/elasticsearch')
|
||||
const client = new Client({
|
||||
node: 'https://localhost:9200',
|
||||
auth: {
|
||||
apiKey: 'base64EncodedKey'
|
||||
}
|
||||
})
|
||||
----
|
||||
|
||||
[source,js]
|
||||
----
|
||||
const { Client } = require('@elastic/elasticsearch')
|
||||
const client = new Client({
|
||||
node: 'https://localhost:9200',
|
||||
auth: {
|
||||
apiKey: {
|
||||
id: 'foo',
|
||||
api_key: 'bar'
|
||||
}
|
||||
}
|
||||
})
|
||||
----
|
||||
|
||||
[discrete]
|
||||
[[auth-bearer]]
|
||||
==== Bearer authentication
|
||||
|
||||
You can provide your credentials by passing the `bearer` token
|
||||
parameter via the `auth` option.
|
||||
Useful for https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-create-service-token.html[service account tokens].
|
||||
Be aware that it does not handle automatic token refresh.
|
||||
|
||||
[source,js]
|
||||
----
|
||||
const { Client } = require('@elastic/elasticsearch')
|
||||
const client = new Client({
|
||||
node: 'https://localhost:9200',
|
||||
auth: {
|
||||
bearer: 'token'
|
||||
}
|
||||
})
|
||||
----
|
||||
|
||||
|
||||
[discrete]
|
||||
[[auth-basic]]
|
||||
==== Basic authentication
|
||||
|
||||
You can provide your credentials by passing the `username` and `password`
|
||||
parameters via the `auth` option.
|
||||
|
||||
NOTE: If you provide both basic authentication credentials and the Api Key
|
||||
configuration, the Api Key will take precedence.
|
||||
|
||||
[source,js]
|
||||
----
|
||||
const { Client } = require('@elastic/elasticsearch')
|
||||
const client = new Client({
|
||||
node: 'https://localhost:9200',
|
||||
auth: {
|
||||
username: 'elastic',
|
||||
password: 'changeme'
|
||||
}
|
||||
})
|
||||
----
|
||||
|
||||
|
||||
Otherwise, you can provide your credentials in the node(s) URL.
|
||||
|
||||
[source,js]
|
||||
----
|
||||
const { Client } = require('@elastic/elasticsearch')
|
||||
const client = new Client({
|
||||
node: 'https://username:password@localhost:9200'
|
||||
})
|
||||
----
|
||||
|
||||
|
||||
[discrete]
|
||||
[[client-usage]]
|
||||
=== Usage
|
||||
|
||||
Using the client is straightforward, it supports all the public APIs of {es},
|
||||
and every method exposes the same signature.
|
||||
|
||||
|
||||
[source,js]
|
||||
----
|
||||
const { Client } = require('@elastic/elasticsearch')
|
||||
const client = new Client({
|
||||
cloud: { id: '<cloud-id>' },
|
||||
auth: { apiKey: 'base64EncodedKey' }
|
||||
})
|
||||
|
||||
const result = await client.search({
|
||||
index: 'my-index',
|
||||
query: {
|
||||
match: { hello: 'world' }
|
||||
}
|
||||
})
|
||||
----
|
||||
|
||||
The returned value of every API call is the response body from {es}.
|
||||
If you need to access additonal metadata, such as the status code or headers,
|
||||
you must specify `meta: true` in the request options:
|
||||
|
||||
[source,js]
|
||||
----
|
||||
const { Client } = require('@elastic/elasticsearch')
|
||||
const client = new Client({
|
||||
cloud: { id: '<cloud-id>' },
|
||||
auth: { apiKey: 'base64EncodedKey' }
|
||||
})
|
||||
|
||||
const result = await client.search({
|
||||
index: 'my-index',
|
||||
query: {
|
||||
match: { hello: 'world' }
|
||||
}
|
||||
}, { meta: true })
|
||||
----
|
||||
|
||||
In this case, the result will be:
|
||||
[source,ts]
|
||||
----
|
||||
{
|
||||
body: object | boolean
|
||||
statusCode: number
|
||||
headers: object
|
||||
warnings: [string],
|
||||
meta: object
|
||||
}
|
||||
----
|
||||
|
||||
NOTE: The body is a boolean value when you use `HEAD` APIs.
|
||||
|
||||
[discrete]
|
||||
==== Aborting a request
|
||||
|
||||
If needed, you can abort a running request by using the `AbortController` standard.
|
||||
|
||||
CAUTION: If you abort a request, the request will fail with a
|
||||
`RequestAbortedError`.
|
||||
|
||||
|
||||
[source,js]
|
||||
----
|
||||
const AbortController = require('node-abort-controller')
|
||||
const { Client } = require('@elastic/elasticsearch')
|
||||
const client = new Client({
|
||||
cloud: { id: '<cloud-id>' },
|
||||
auth: { apiKey: 'base64EncodedKey' }
|
||||
})
|
||||
|
||||
const abortController = new AbortController()
|
||||
setImmediate(() => abortController.abort())
|
||||
|
||||
const result = await client.search({
|
||||
index: 'my-index',
|
||||
query: {
|
||||
match: { hello: 'world' }
|
||||
}
|
||||
}, { signal: abortController.signal })
|
||||
----
|
||||
|
||||
[discrete]
|
||||
==== Request specific options
|
||||
|
||||
If needed you can pass request specific options in a second object:
|
||||
|
||||
[source,js]
|
||||
----
|
||||
const result = await client.search({
|
||||
index: 'my-index',
|
||||
body: {
|
||||
query: {
|
||||
match: { hello: 'world' }
|
||||
}
|
||||
}
|
||||
}, {
|
||||
ignore: [404],
|
||||
maxRetries: 3
|
||||
})
|
||||
----
|
||||
|
||||
|
||||
The supported request specific options are:
|
||||
[cols=2*]
|
||||
|===
|
||||
|`ignore`
|
||||
|`[number]` - HTTP status codes which should not be considered errors for this request. +
|
||||
_Default:_ `null`
|
||||
|
||||
|`requestTimeout`
|
||||
|`number` - Max request timeout for the request in milliseconds, it overrides the client default. +
|
||||
_Default:_ `30000`
|
||||
|
||||
|`maxRetries`
|
||||
|`number` - Max number of retries for the request, it overrides the client default. +
|
||||
_Default:_ `3`
|
||||
|
||||
|`compression`
|
||||
|`string, boolean` - Enables body compression for the request. +
|
||||
_Options:_ `false`, `'gzip'` +
|
||||
_Default:_ `false`
|
||||
|
||||
|`asStream`
|
||||
|`boolean` - Instead of getting the parsed body back, you get the raw Node.js stream of data. +
|
||||
_Default:_ `false`
|
||||
|
||||
|`headers`
|
||||
|`object` - Custom headers for the request. +
|
||||
_Default:_ `null`
|
||||
|
||||
|`querystring`
|
||||
|`object` - Custom querystring for the request. +
|
||||
_Default:_ `null`
|
||||
|
||||
|`id`
|
||||
|`any` - Custom request id. _(overrides the top level request id generator)_ +
|
||||
_Default:_ `null`
|
||||
|
||||
|`context`
|
||||
|`any` - Custom object per request. _(you can use it to pass data to the clients events)_ +
|
||||
_Default:_ `null`
|
||||
|
||||
|`maxResponseSize`
|
||||
|`number` - When configured, it verifies that the uncompressed response size is lower than the configured number, if it's higher it will abort the request. It cannot be higher than buffer.constants.MAX_STRING_LENTGH +
|
||||
_Default:_ `null`
|
||||
|
||||
|`maxCompressedResponseSize`
|
||||
|`number` - When configured, it verifies that the compressed response size is lower than the configured number, if it's higher it will abort the request. It cannot be higher than buffer.constants.MAX_LENTGH +
|
||||
_Default:_ `null`
|
||||
|
||||
|`signal`
|
||||
|`AbortSignal` - The AbortSignal instance to allow request abortion. +
|
||||
_Default:_ `null`
|
||||
|
||||
|===
|
||||
|
||||
[discrete]
|
||||
[[client-faas-env]]
|
||||
=== Using the Client in a Function-as-a-Service Environment
|
||||
|
||||
This section illustrates the best practices for leveraging the {es} client in a Function-as-a-Service (FaaS) environment.
|
||||
The most influential optimization is to initialize the client outside of the function, the global scope.
|
||||
This practice does not only improve performance but also enables background functionality as – for example – https://www.elastic.co/blog/elasticsearch-sniffing-best-practices-what-when-why-how[sniffing].
|
||||
The following examples provide a skeleton for the best practices.
|
||||
|
||||
[discrete]
|
||||
==== GCP Cloud Functions
|
||||
|
||||
[source,js]
|
||||
----
|
||||
'use strict'
|
||||
|
||||
const { Client } = require('@elastic/elasticsearch')
|
||||
|
||||
const client = new Client({
|
||||
// client initialisation
|
||||
})
|
||||
|
||||
exports.testFunction = async function (req, res) {
|
||||
// use the client
|
||||
}
|
||||
----
|
||||
|
||||
[discrete]
|
||||
==== AWS Lambda
|
||||
|
||||
[source,js]
|
||||
----
|
||||
'use strict'
|
||||
|
||||
const { Client } = require('@elastic/elasticsearch')
|
||||
|
||||
const client = new Client({
|
||||
// client initialisation
|
||||
})
|
||||
|
||||
exports.handler = async function (event, context) {
|
||||
// use the client
|
||||
}
|
||||
----
|
||||
|
||||
[discrete]
|
||||
==== Azure Functions
|
||||
|
||||
[source,js]
|
||||
----
|
||||
'use strict'
|
||||
|
||||
const { Client } = require('@elastic/elasticsearch')
|
||||
|
||||
const client = new Client({
|
||||
// client initialisation
|
||||
})
|
||||
|
||||
module.exports = async function (context, req) {
|
||||
// use the client
|
||||
}
|
||||
----
|
||||
|
||||
Resources used to assess these recommendations:
|
||||
|
||||
- https://cloud.google.com/functions/docs/bestpractices/tips#use_global_variables_to_reuse_objects_in_future_invocations[GCP Cloud Functions: Tips & Tricks]
|
||||
- https://docs.aws.amazon.com/lambda/latest/dg/best-practices.html[Best practices for working with AWS Lambda functions]
|
||||
- https://docs.microsoft.com/en-us/azure/azure-functions/functions-reference-python?tabs=azurecli-linux%2Capplication-level#global-variables[Azure Functions Python developer guide]
|
||||
- https://docs.aws.amazon.com/lambda/latest/operatorguide/global-scope.html[AWS Lambda: Comparing the effect of global scope]
|
||||
|
||||
|
||||
[discrete]
|
||||
[[client-connect-proxy]]
|
||||
=== Connecting through a proxy
|
||||
|
||||
~Added~ ~in~ ~`v7.10.0`~
|
||||
|
||||
If you need to pass through an http(s) proxy for connecting to {es}, the client
|
||||
out of the box offers a handy configuration for helping you with it. Under the
|
||||
hood, it uses the https://github.com/delvedor/hpagent[`hpagent`] module.
|
||||
|
||||
IMPORTANT: In versions 8.0+ of the client, the default `Connection` type is set to `UndiciConnection`, which does not support proxy configurations.
|
||||
To use a proxy, you will need to use the `HttpConnection` class from `@elastic/transport` instead.
|
||||
|
||||
[source,js]
|
||||
----
|
||||
import { HttpConnection } from '@elastic/transport'
|
||||
|
||||
const client = new Client({
|
||||
node: 'http://localhost:9200',
|
||||
proxy: 'http://localhost:8080',
|
||||
Connection: HttpConnection,
|
||||
})
|
||||
----
|
||||
|
||||
Basic authentication is supported as well:
|
||||
|
||||
[source,js]
|
||||
----
|
||||
const client = new Client({
|
||||
node: 'http://localhost:9200',
|
||||
proxy: 'http:user:pwd@//localhost:8080',
|
||||
Connection: HttpConnection,
|
||||
})
|
||||
----
|
||||
|
||||
If you are connecting through a non-http(s) proxy, such as a `socks5` or `pac`,
|
||||
you can use the `agent` option to configure it.
|
||||
|
||||
[source,js]
|
||||
----
|
||||
const SocksProxyAgent = require('socks-proxy-agent')
|
||||
const client = new Client({
|
||||
node: 'http://localhost:9200',
|
||||
agent () {
|
||||
return new SocksProxyAgent('socks://127.0.0.1:1080')
|
||||
},
|
||||
Connection: HttpConnection,
|
||||
})
|
||||
----
|
||||
|
||||
|
||||
[discrete]
|
||||
[[client-error-handling]]
|
||||
=== Error handling
|
||||
|
||||
The client exposes a variety of error objects that you can use to enhance your
|
||||
error handling. You can find all the error objects inside the `errors` key in
|
||||
the client.
|
||||
|
||||
[source,js]
|
||||
----
|
||||
const { errors } = require('@elastic/elasticsearch')
|
||||
console.log(errors)
|
||||
----
|
||||
|
||||
|
||||
You can find the errors exported by the client in the table below.
|
||||
|
||||
[cols=3*]
|
||||
|===
|
||||
|*Error*
|
||||
|*Description*
|
||||
|*Properties*
|
||||
|
||||
|`ElasticsearchClientError`
|
||||
|Every error inherits from this class, it is the basic error generated by the client.
|
||||
a|* `name` - `string`
|
||||
* `message` - `string`
|
||||
|
||||
|`TimeoutError`
|
||||
|Generated when a request exceeds the `requestTimeout` option.
|
||||
a|* `name` - `string`
|
||||
* `message` - `string`
|
||||
* `meta` - `object`, contains all the information about the request
|
||||
|
||||
|`ConnectionError`
|
||||
|Generated when an error occurs during the request, it can be a connection error or a malformed stream of data.
|
||||
a|* `name` - `string`
|
||||
* `message` - `string`
|
||||
* `meta` - `object`, contains all the information about the request
|
||||
|
||||
|`RequestAbortedError`
|
||||
|Generated if the user calls the `request.abort()` method.
|
||||
a|* `name` - `string`
|
||||
* `message` - `string`
|
||||
* `meta` - `object`, contains all the information about the request
|
||||
|
||||
|`NoLivingConnectionsError`
|
||||
|Given the configuration, the ConnectionPool was not able to find a usable Connection for this request.
|
||||
a|* `name` - `string`
|
||||
* `message` - `string`
|
||||
* `meta` - `object`, contains all the information about the request
|
||||
|
||||
|`SerializationError`
|
||||
|Generated if the serialization fails.
|
||||
a|* `name` - `string`
|
||||
* `message` - `string`
|
||||
* `data` - `object`, the object to serialize
|
||||
|
||||
|`DeserializationError`
|
||||
|Generated if the deserialization fails.
|
||||
a|* `name` - `string`
|
||||
* `message` - `string`
|
||||
* `data` - `string`, the string to deserialize
|
||||
|
||||
|`ConfigurationError`
|
||||
|Generated if there is a malformed configuration or parameter.
|
||||
a|* `name` - `string`
|
||||
* `message` - `string`
|
||||
|
||||
|`ResponseError`
|
||||
|Generated when in case of a `4xx` or `5xx` response.
|
||||
a|* `name` - `string`
|
||||
* `message` - `string`
|
||||
* `meta` - `object`, contains all the information about the request
|
||||
* `body` - `object`, the response body
|
||||
* `statusCode` - `object`, the response headers
|
||||
* `headers` - `object`, the response status code
|
||||
|===
|
||||
|
||||
[[keep-alive]]
|
||||
[discrete]
|
||||
=== Keep-alive connections
|
||||
|
||||
By default, the client uses persistent, keep-alive connections to reduce the overhead of creating a new HTTP connection for each Elasticsearch request.
|
||||
If you are using the default `UndiciConnection` connection class, it maintains a pool of 256 connections with a keep-alive of 10 minutes.
|
||||
If you are using the legacy `HttpConnection` connection class, it maintains a pool of 256 connections with a keep-alive of 1 minute.
|
||||
|
||||
If you need to disable keep-alive connections, you can override the HTTP agent with your preferred https://nodejs.org/api/http.html#http_new_agent_options[HTTP agent options]:
|
||||
|
||||
[source,js]
|
||||
----
|
||||
const client = new Client({
|
||||
node: 'http://localhost:9200',
|
||||
// the function takes as parameter the option
|
||||
// object passed to the Connection constructor
|
||||
agent: (opts) => new CustomAgent()
|
||||
})
|
||||
----
|
||||
|
||||
Or you can disable the HTTP agent entirely:
|
||||
|
||||
[source,js]
|
||||
----
|
||||
const client = new Client({
|
||||
node: 'http://localhost:9200',
|
||||
// Disable agent and keep-alive
|
||||
agent: false
|
||||
})
|
||||
----
|
||||
|
||||
[discrete]
|
||||
[[product-check]]
|
||||
=== Automatic product check
|
||||
|
||||
Since v7.14.0, the client performs a required product check before the first call.
|
||||
This pre-flight product check allows the client to establish the version of Elasticsearch
|
||||
that it is communicating with. The product check requires one additional HTTP request to
|
||||
be sent to the server as part of the request pipeline before the main API call is sent.
|
||||
In most cases, this will succeed during the very first API call that the client sends.
|
||||
Once the product check completes, no further product check HTTP requests are sent for
|
||||
subsequent API calls.
|
||||
10
docs/doc_examples/00272f75a6afea91f8554ef7cda0c1f2.asciidoc
Normal file
10
docs/doc_examples/00272f75a6afea91f8554ef7cda0c1f2.asciidoc
Normal file
@ -0,0 +1,10 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.security.clearCachedRealms({
|
||||
realms: "default_file,ldap1",
|
||||
});
|
||||
console.log(response);
|
||||
----
|
||||
11
docs/doc_examples/004743b9c9f61588926ccf734696b713.asciidoc
Normal file
11
docs/doc_examples/004743b9c9f61588926ccf734696b713.asciidoc
Normal file
@ -0,0 +1,11 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.indices.forcemerge({
|
||||
index: ".ds-my-data-stream-2099.03.07-000001",
|
||||
max_num_segments: 1,
|
||||
});
|
||||
console.log(response);
|
||||
----
|
||||
19
docs/doc_examples/004a17b42ab5155bb61da797a006fa9f.asciidoc
Normal file
19
docs/doc_examples/004a17b42ab5155bb61da797a006fa9f.asciidoc
Normal file
@ -0,0 +1,19 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.search({
|
||||
query: {
|
||||
pinned: {
|
||||
ids: ["1", "4", "100"],
|
||||
organic: {
|
||||
match: {
|
||||
description: "iphone",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
console.log(response);
|
||||
----
|
||||
20
docs/doc_examples/006e0e16c9f1da58c0bfe57377f7fc38.asciidoc
Normal file
20
docs/doc_examples/006e0e16c9f1da58c0bfe57377f7fc38.asciidoc
Normal file
@ -0,0 +1,20 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.indices.create({
|
||||
index: "my-index-000001",
|
||||
settings: {
|
||||
analysis: {
|
||||
analyzer: {
|
||||
my_analyzer: {
|
||||
tokenizer: "whitespace",
|
||||
filter: ["stemmer"],
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
console.log(response);
|
||||
----
|
||||
40
docs/doc_examples/007179b5e241da650562a5f0a5007823.asciidoc
Normal file
40
docs/doc_examples/007179b5e241da650562a5f0a5007823.asciidoc
Normal file
@ -0,0 +1,40 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.watcher.putWatch({
|
||||
id: "cluster_health_watch",
|
||||
trigger: {
|
||||
schedule: {
|
||||
interval: "10s",
|
||||
},
|
||||
},
|
||||
input: {
|
||||
http: {
|
||||
request: {
|
||||
host: "localhost",
|
||||
port: 9200,
|
||||
path: "/_cluster/health",
|
||||
},
|
||||
},
|
||||
},
|
||||
condition: {
|
||||
compare: {
|
||||
"ctx.payload.status": {
|
||||
eq: "red",
|
||||
},
|
||||
},
|
||||
},
|
||||
actions: {
|
||||
send_email: {
|
||||
email: {
|
||||
to: "username@example.org",
|
||||
subject: "Cluster Status Warning",
|
||||
body: "Cluster status is RED",
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
console.log(response);
|
||||
----
|
||||
@ -0,0 +1,8 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.migration.postFeatureUpgrade();
|
||||
console.log(response);
|
||||
----
|
||||
16
docs/doc_examples/0091fc75271b1fbbd4269622a4881e8b.asciidoc
Normal file
16
docs/doc_examples/0091fc75271b1fbbd4269622a4881e8b.asciidoc
Normal file
@ -0,0 +1,16 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.search({
|
||||
index: "my-index",
|
||||
query: {
|
||||
match: {
|
||||
"http.clientip": "40.135.0.0",
|
||||
},
|
||||
},
|
||||
fields: ["http.clientip"],
|
||||
});
|
||||
console.log(response);
|
||||
----
|
||||
11
docs/doc_examples/00ad41bde67beac991534ae0e04b1296.asciidoc
Normal file
11
docs/doc_examples/00ad41bde67beac991534ae0e04b1296.asciidoc
Normal file
@ -0,0 +1,11 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.indices.getDataStream({
|
||||
name: "my-data-stream",
|
||||
filter_path: "data_streams.indices.index_name",
|
||||
});
|
||||
console.log(response);
|
||||
----
|
||||
@ -0,0 +1,8 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.indices.shardStores();
|
||||
console.log(response);
|
||||
----
|
||||
15
docs/doc_examples/00c05aa931fc985985e3e21c93cf43ff.asciidoc
Normal file
15
docs/doc_examples/00c05aa931fc985985e3e21c93cf43ff.asciidoc
Normal file
@ -0,0 +1,15 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.renderSearchTemplate({
|
||||
source: '{ "query": {{#toJson}}my_query{{/toJson}} }',
|
||||
params: {
|
||||
my_query: {
|
||||
match_all: {},
|
||||
},
|
||||
},
|
||||
});
|
||||
console.log(response);
|
||||
----
|
||||
12
docs/doc_examples/00d65f7b9daa1c6b18eedd8ace206bae.asciidoc
Normal file
12
docs/doc_examples/00d65f7b9daa1c6b18eedd8ace206bae.asciidoc
Normal file
@ -0,0 +1,12 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.indices.analyze({
|
||||
tokenizer: "standard",
|
||||
filter: ["asciifolding"],
|
||||
text: "açaí à la carte",
|
||||
});
|
||||
console.log(response);
|
||||
----
|
||||
67
docs/doc_examples/00e0c964c79fcc1876ab957da2ffce82.asciidoc
Normal file
67
docs/doc_examples/00e0c964c79fcc1876ab957da2ffce82.asciidoc
Normal file
@ -0,0 +1,67 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.indices.create({
|
||||
index: "italian_example",
|
||||
settings: {
|
||||
analysis: {
|
||||
filter: {
|
||||
italian_elision: {
|
||||
type: "elision",
|
||||
articles: [
|
||||
"c",
|
||||
"l",
|
||||
"all",
|
||||
"dall",
|
||||
"dell",
|
||||
"nell",
|
||||
"sull",
|
||||
"coll",
|
||||
"pell",
|
||||
"gl",
|
||||
"agl",
|
||||
"dagl",
|
||||
"degl",
|
||||
"negl",
|
||||
"sugl",
|
||||
"un",
|
||||
"m",
|
||||
"t",
|
||||
"s",
|
||||
"v",
|
||||
"d",
|
||||
],
|
||||
articles_case: true,
|
||||
},
|
||||
italian_stop: {
|
||||
type: "stop",
|
||||
stopwords: "_italian_",
|
||||
},
|
||||
italian_keywords: {
|
||||
type: "keyword_marker",
|
||||
keywords: ["esempio"],
|
||||
},
|
||||
italian_stemmer: {
|
||||
type: "stemmer",
|
||||
language: "light_italian",
|
||||
},
|
||||
},
|
||||
analyzer: {
|
||||
rebuilt_italian: {
|
||||
tokenizer: "standard",
|
||||
filter: [
|
||||
"italian_elision",
|
||||
"lowercase",
|
||||
"italian_stop",
|
||||
"italian_keywords",
|
||||
"italian_stemmer",
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
console.log(response);
|
||||
----
|
||||
19
docs/doc_examples/00fea15cbca83be9d5f1a024ff2ec708.asciidoc
Normal file
19
docs/doc_examples/00fea15cbca83be9d5f1a024ff2ec708.asciidoc
Normal file
@ -0,0 +1,19 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.inference.put({
|
||||
task_type: "text_embedding",
|
||||
inference_id: "my-e5-model",
|
||||
inference_config: {
|
||||
service: "elasticsearch",
|
||||
service_settings: {
|
||||
num_allocations: 1,
|
||||
num_threads: 1,
|
||||
model_id: ".multilingual-e5-small",
|
||||
},
|
||||
},
|
||||
});
|
||||
console.log(response);
|
||||
----
|
||||
13
docs/doc_examples/010d5e901a2690fa7b2396edbe6cd463.asciidoc
Normal file
13
docs/doc_examples/010d5e901a2690fa7b2396edbe6cd463.asciidoc
Normal file
@ -0,0 +1,13 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.indices.putIndexTemplate({
|
||||
name: "my-data-stream-template",
|
||||
index_patterns: ["my-data-stream*"],
|
||||
data_stream: {},
|
||||
priority: 500,
|
||||
});
|
||||
console.log(response);
|
||||
----
|
||||
@ -1,15 +0,0 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.cluster.putSettings({
|
||||
body: {
|
||||
transient: {
|
||||
'cluster.routing.use_adaptive_replica_selection': false
|
||||
}
|
||||
}
|
||||
})
|
||||
console.log(response)
|
||||
----
|
||||
|
||||
@ -1,18 +0,0 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.update({
|
||||
index: 'test',
|
||||
id: '1',
|
||||
body: {
|
||||
doc: {
|
||||
name: 'new_name'
|
||||
},
|
||||
detect_noop: false
|
||||
}
|
||||
})
|
||||
console.log(response)
|
||||
----
|
||||
|
||||
46
docs/doc_examples/015e6e6132b6d6d44bddb06bc3b316ed.asciidoc
Normal file
46
docs/doc_examples/015e6e6132b6d6d44bddb06bc3b316ed.asciidoc
Normal file
@ -0,0 +1,46 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.search({
|
||||
index: "retrievers_example",
|
||||
retriever: {
|
||||
rrf: {
|
||||
retrievers: [
|
||||
{
|
||||
standard: {
|
||||
query: {
|
||||
range: {
|
||||
year: {
|
||||
gt: 2023,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
standard: {
|
||||
query: {
|
||||
term: {
|
||||
topic: "elastic",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
rank_window_size: 10,
|
||||
rank_constant: 1,
|
||||
},
|
||||
},
|
||||
_source: false,
|
||||
aggs: {
|
||||
topics: {
|
||||
terms: {
|
||||
field: "topic",
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
console.log(response);
|
||||
----
|
||||
24
docs/doc_examples/0163af36c8472ac0c5160c8b716f5b26.asciidoc
Normal file
24
docs/doc_examples/0163af36c8472ac0c5160c8b716f5b26.asciidoc
Normal file
@ -0,0 +1,24 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.search({
|
||||
index: "sales",
|
||||
size: 0,
|
||||
filter_path: "aggregations",
|
||||
query: {
|
||||
term: {
|
||||
type: "t-shirt",
|
||||
},
|
||||
},
|
||||
aggs: {
|
||||
avg_price: {
|
||||
avg: {
|
||||
field: "price",
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
console.log(response);
|
||||
----
|
||||
18
docs/doc_examples/0165d22da5f2fc7678392b31d8eb5566.asciidoc
Normal file
18
docs/doc_examples/0165d22da5f2fc7678392b31d8eb5566.asciidoc
Normal file
@ -0,0 +1,18 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.inference.put({
|
||||
task_type: "rerank",
|
||||
inference_id: "my-rerank-model",
|
||||
inference_config: {
|
||||
service: "cohere",
|
||||
service_settings: {
|
||||
model_id: "rerank-english-v3.0",
|
||||
api_key: "{{COHERE_API_KEY}}",
|
||||
},
|
||||
},
|
||||
});
|
||||
console.log(response);
|
||||
----
|
||||
17
docs/doc_examples/016f3147dae9ff2c3e831257ae470361.asciidoc
Normal file
17
docs/doc_examples/016f3147dae9ff2c3e831257ae470361.asciidoc
Normal file
@ -0,0 +1,17 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.indices.updateAliases({
|
||||
actions: [
|
||||
{
|
||||
add: {
|
||||
index: "logs-*",
|
||||
alias: "logs",
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
console.log(response);
|
||||
----
|
||||
26
docs/doc_examples/019e329ed5a930aef825266822e7377a.asciidoc
Normal file
26
docs/doc_examples/019e329ed5a930aef825266822e7377a.asciidoc
Normal file
@ -0,0 +1,26 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.indices.create({
|
||||
index: "asciifold_example",
|
||||
settings: {
|
||||
analysis: {
|
||||
analyzer: {
|
||||
standard_asciifolding: {
|
||||
tokenizer: "standard",
|
||||
filter: ["my_ascii_folding"],
|
||||
},
|
||||
},
|
||||
filter: {
|
||||
my_ascii_folding: {
|
||||
type: "asciifolding",
|
||||
preserve_original: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
console.log(response);
|
||||
----
|
||||
36
docs/doc_examples/01ae196538fac197eedbbf458a4ef31b.asciidoc
Normal file
36
docs/doc_examples/01ae196538fac197eedbbf458a4ef31b.asciidoc
Normal file
@ -0,0 +1,36 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.indices.create({
|
||||
index: "idx",
|
||||
settings: {
|
||||
index: {
|
||||
mapping: {
|
||||
source: {
|
||||
mode: "synthetic",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
mappings: {
|
||||
properties: {
|
||||
kwd: {
|
||||
type: "keyword",
|
||||
ignore_above: 3,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
console.log(response);
|
||||
|
||||
const response1 = await client.index({
|
||||
index: "idx",
|
||||
id: 1,
|
||||
document: {
|
||||
kwd: ["foo", "foo", "bang", "bar", "baz"],
|
||||
},
|
||||
});
|
||||
console.log(response1);
|
||||
----
|
||||
37
docs/doc_examples/01b23f09d2b7f140faf649eadbbf3ac3.asciidoc
Normal file
37
docs/doc_examples/01b23f09d2b7f140faf649eadbbf3ac3.asciidoc
Normal file
@ -0,0 +1,37 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.cluster.putComponentTemplate({
|
||||
name: "component_template1",
|
||||
template: {
|
||||
mappings: {
|
||||
properties: {
|
||||
"@timestamp": {
|
||||
type: "date",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
console.log(response);
|
||||
|
||||
const response1 = await client.cluster.putComponentTemplate({
|
||||
name: "runtime_component_template",
|
||||
template: {
|
||||
mappings: {
|
||||
runtime: {
|
||||
day_of_week: {
|
||||
type: "keyword",
|
||||
script: {
|
||||
source:
|
||||
"emit(doc['@timestamp'].value.dayOfWeekEnum.getDisplayName(TextStyle.FULL, Locale.ENGLISH))",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
console.log(response1);
|
||||
----
|
||||
10
docs/doc_examples/01bc0f2ed30eb3dd23511d01ce0ac6e1.asciidoc
Normal file
10
docs/doc_examples/01bc0f2ed30eb3dd23511d01ce0ac6e1.asciidoc
Normal file
@ -0,0 +1,10 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.transform.startTransform({
|
||||
transform_id: "ecommerce_transform",
|
||||
});
|
||||
console.log(response);
|
||||
----
|
||||
12
docs/doc_examples/01cd0ea360282a2c591a366679d7187d.asciidoc
Normal file
12
docs/doc_examples/01cd0ea360282a2c591a366679d7187d.asciidoc
Normal file
@ -0,0 +1,12 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.tasks.list({
|
||||
human: "true",
|
||||
detailed: "true",
|
||||
actions: "indices:data/write/bulk",
|
||||
});
|
||||
console.log(response);
|
||||
----
|
||||
17
docs/doc_examples/01da9e0620e48270617fc248e6415cac.asciidoc
Normal file
17
docs/doc_examples/01da9e0620e48270617fc248e6415cac.asciidoc
Normal file
@ -0,0 +1,17 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.search({
|
||||
index: "my-index-000001",
|
||||
aggs: {
|
||||
"my-agg-name": {
|
||||
terms: {
|
||||
field: "my-field",
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
console.log(response);
|
||||
----
|
||||
10
docs/doc_examples/01dc7bdc223bd651574ed2d3954a5b1c.asciidoc
Normal file
10
docs/doc_examples/01dc7bdc223bd651574ed2d3954a5b1c.asciidoc
Normal file
@ -0,0 +1,10 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.watcher.executeWatch({
|
||||
id: "my_watch",
|
||||
});
|
||||
console.log(response);
|
||||
----
|
||||
39
docs/doc_examples/01f50acf7998b24969f451e922d145eb.asciidoc
Normal file
39
docs/doc_examples/01f50acf7998b24969f451e922d145eb.asciidoc
Normal file
@ -0,0 +1,39 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.indices.create({
|
||||
index: "basque_example",
|
||||
settings: {
|
||||
analysis: {
|
||||
filter: {
|
||||
basque_stop: {
|
||||
type: "stop",
|
||||
stopwords: "_basque_",
|
||||
},
|
||||
basque_keywords: {
|
||||
type: "keyword_marker",
|
||||
keywords: ["Adibidez"],
|
||||
},
|
||||
basque_stemmer: {
|
||||
type: "stemmer",
|
||||
language: "basque",
|
||||
},
|
||||
},
|
||||
analyzer: {
|
||||
rebuilt_basque: {
|
||||
tokenizer: "standard",
|
||||
filter: [
|
||||
"lowercase",
|
||||
"basque_stop",
|
||||
"basque_keywords",
|
||||
"basque_stemmer",
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
console.log(response);
|
||||
----
|
||||
10
docs/doc_examples/020c95db88ef356093f03be84893ddf9.asciidoc
Normal file
10
docs/doc_examples/020c95db88ef356093f03be84893ddf9.asciidoc
Normal file
@ -0,0 +1,10 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.ccr.followStats({
|
||||
index: "<index>",
|
||||
});
|
||||
console.log(response);
|
||||
----
|
||||
20
docs/doc_examples/020de6b6cb960a76297452725a38889f.asciidoc
Normal file
20
docs/doc_examples/020de6b6cb960a76297452725a38889f.asciidoc
Normal file
@ -0,0 +1,20 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.search({
|
||||
query: {
|
||||
has_child: {
|
||||
type: "child",
|
||||
query: {
|
||||
match_all: {},
|
||||
},
|
||||
max_children: 10,
|
||||
min_children: 2,
|
||||
score_mode: "min",
|
||||
},
|
||||
},
|
||||
});
|
||||
console.log(response);
|
||||
----
|
||||
19
docs/doc_examples/0246f73cc2ed3dfec577119e8cd15404.asciidoc
Normal file
19
docs/doc_examples/0246f73cc2ed3dfec577119e8cd15404.asciidoc
Normal file
@ -0,0 +1,19 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.indices.putMapping({
|
||||
index: "my-index-000001",
|
||||
properties: {
|
||||
name: {
|
||||
properties: {
|
||||
last: {
|
||||
type: "text",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
console.log(response);
|
||||
----
|
||||
28
docs/doc_examples/025155da86802ebf4c3aeee5aab692f9.asciidoc
Normal file
28
docs/doc_examples/025155da86802ebf4c3aeee5aab692f9.asciidoc
Normal file
@ -0,0 +1,28 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.indices.create({
|
||||
index: "sales",
|
||||
mappings: {
|
||||
properties: {
|
||||
tags: {
|
||||
type: "keyword",
|
||||
},
|
||||
comments: {
|
||||
type: "nested",
|
||||
properties: {
|
||||
username: {
|
||||
type: "keyword",
|
||||
},
|
||||
comment: {
|
||||
type: "text",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
console.log(response);
|
||||
----
|
||||
11
docs/doc_examples/02520ac7816b2c4cf8fb413fd16122f2.asciidoc
Normal file
11
docs/doc_examples/02520ac7816b2c4cf8fb413fd16122f2.asciidoc
Normal file
@ -0,0 +1,11 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.ml.flushJob({
|
||||
job_id: "low_request_rate",
|
||||
calc_interim: true,
|
||||
});
|
||||
console.log(response);
|
||||
----
|
||||
@ -1,14 +0,0 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.search({
|
||||
index: 'twitter',
|
||||
size: '0',
|
||||
q: 'extra:test',
|
||||
filter_path: 'hits.total'
|
||||
})
|
||||
console.log(response)
|
||||
----
|
||||
|
||||
23
docs/doc_examples/0264e994a7e68561e2ca6be0f0d90ee9.asciidoc
Normal file
23
docs/doc_examples/0264e994a7e68561e2ca6be0f0d90ee9.asciidoc
Normal file
@ -0,0 +1,23 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.search({
|
||||
aggs: {
|
||||
JapaneseCars: {
|
||||
terms: {
|
||||
field: "make",
|
||||
include: ["mazda", "honda"],
|
||||
},
|
||||
},
|
||||
ActiveCarManufacturers: {
|
||||
terms: {
|
||||
field: "make",
|
||||
exclude: ["rover", "jensen"],
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
console.log(response);
|
||||
----
|
||||
10
docs/doc_examples/0280247e0cf2e561c548f22c9fb31163.asciidoc
Normal file
10
docs/doc_examples/0280247e0cf2e561c548f22c9fb31163.asciidoc
Normal file
@ -0,0 +1,10 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.security.invalidateToken({
|
||||
username: "myuser",
|
||||
});
|
||||
console.log(response);
|
||||
----
|
||||
28
docs/doc_examples/02853293a5b7cd9cc7a886eb413bbeb6.asciidoc
Normal file
28
docs/doc_examples/02853293a5b7cd9cc7a886eb413bbeb6.asciidoc
Normal file
@ -0,0 +1,28 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.indices.analyze({
|
||||
tokenizer: "keyword",
|
||||
char_filter: [
|
||||
{
|
||||
type: "mapping",
|
||||
mappings: [
|
||||
"٠ => 0",
|
||||
"١ => 1",
|
||||
"٢ => 2",
|
||||
"٣ => 3",
|
||||
"٤ => 4",
|
||||
"٥ => 5",
|
||||
"٦ => 6",
|
||||
"٧ => 7",
|
||||
"٨ => 8",
|
||||
"٩ => 9",
|
||||
],
|
||||
},
|
||||
],
|
||||
text: "My license plate is ٢٥٠١٥",
|
||||
});
|
||||
console.log(response);
|
||||
----
|
||||
@ -1,43 +0,0 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.search({
|
||||
body: {
|
||||
aggs: {
|
||||
countries: {
|
||||
terms: {
|
||||
field: 'artist.country',
|
||||
order: [
|
||||
{
|
||||
'rock>playback_stats.avg': 'desc'
|
||||
},
|
||||
{
|
||||
_count: 'desc'
|
||||
}
|
||||
]
|
||||
},
|
||||
aggs: {
|
||||
rock: {
|
||||
filter: {
|
||||
term: {
|
||||
genre: 'rock'
|
||||
}
|
||||
},
|
||||
aggs: {
|
||||
playback_stats: {
|
||||
stats: {
|
||||
field: 'play_count'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
console.log(response)
|
||||
----
|
||||
|
||||
21
docs/doc_examples/029de2f5383a42e1ac4ca1565bd2a130.asciidoc
Normal file
21
docs/doc_examples/029de2f5383a42e1ac4ca1565bd2a130.asciidoc
Normal file
@ -0,0 +1,21 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.indices.create({
|
||||
index: "my-index-000001",
|
||||
mappings: {
|
||||
properties: {
|
||||
full_name: {
|
||||
type: "text",
|
||||
index_prefixes: {
|
||||
min_chars: 1,
|
||||
max_chars: 10,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
console.log(response);
|
||||
----
|
||||
16
docs/doc_examples/02b00f21e9d23d82276ace0dd154d779.asciidoc
Normal file
16
docs/doc_examples/02b00f21e9d23d82276ace0dd154d779.asciidoc
Normal file
@ -0,0 +1,16 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.search({
|
||||
index: "my-index-000001",
|
||||
routing: "user1,user2",
|
||||
query: {
|
||||
match: {
|
||||
title: "document",
|
||||
},
|
||||
},
|
||||
});
|
||||
console.log(response);
|
||||
----
|
||||
10
docs/doc_examples/02b6aa3e5652839f03de3a655854b897.asciidoc
Normal file
10
docs/doc_examples/02b6aa3e5652839f03de3a655854b897.asciidoc
Normal file
@ -0,0 +1,10 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.search({
|
||||
index: "my-data-stream",
|
||||
});
|
||||
console.log(response);
|
||||
----
|
||||
24
docs/doc_examples/02c48d461536709c3fc8a0e8147c3787.asciidoc
Normal file
24
docs/doc_examples/02c48d461536709c3fc8a0e8147c3787.asciidoc
Normal file
@ -0,0 +1,24 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.ingest.putPipeline({
|
||||
id: "pipelineB",
|
||||
description: "outer pipeline",
|
||||
processors: [
|
||||
{
|
||||
pipeline: {
|
||||
name: "pipelineA",
|
||||
},
|
||||
},
|
||||
{
|
||||
set: {
|
||||
field: "outer_pipeline_set",
|
||||
value: "outer",
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
console.log(response);
|
||||
----
|
||||
10
docs/doc_examples/02f65c6bab8f40bf3ce18160623d1870.asciidoc
Normal file
10
docs/doc_examples/02f65c6bab8f40bf3ce18160623d1870.asciidoc
Normal file
@ -0,0 +1,10 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.indices.getTemplate({
|
||||
name: "template_1",
|
||||
});
|
||||
console.log(response);
|
||||
----
|
||||
38
docs/doc_examples/02fad6b80bb29c2a7e6840db2fc67b18.asciidoc
Normal file
38
docs/doc_examples/02fad6b80bb29c2a7e6840db2fc67b18.asciidoc
Normal file
@ -0,0 +1,38 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.indices.create({
|
||||
index: "my-index-000001",
|
||||
mappings: {
|
||||
properties: {
|
||||
my_wildcard: {
|
||||
type: "wildcard",
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
console.log(response);
|
||||
|
||||
const response1 = await client.index({
|
||||
index: "my-index-000001",
|
||||
id: 1,
|
||||
document: {
|
||||
my_wildcard: "This string can be quite lengthy",
|
||||
},
|
||||
});
|
||||
console.log(response1);
|
||||
|
||||
const response2 = await client.search({
|
||||
index: "my-index-000001",
|
||||
query: {
|
||||
wildcard: {
|
||||
my_wildcard: {
|
||||
value: "*quite*lengthy",
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
console.log(response2);
|
||||
----
|
||||
12
docs/doc_examples/0308cbd85281f95fc458042afe3f587d.asciidoc
Normal file
12
docs/doc_examples/0308cbd85281f95fc458042afe3f587d.asciidoc
Normal file
@ -0,0 +1,12 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.get({
|
||||
index: "my-index-000001",
|
||||
id: 0,
|
||||
_source: "*.id",
|
||||
});
|
||||
console.log(response);
|
||||
----
|
||||
10
docs/doc_examples/032eac56b798bea29390e102538f4a26.asciidoc
Normal file
10
docs/doc_examples/032eac56b798bea29390e102538f4a26.asciidoc
Normal file
@ -0,0 +1,10 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.indices.refresh({
|
||||
index: "my-index-000001,my-index-000002",
|
||||
});
|
||||
console.log(response);
|
||||
----
|
||||
@ -1,22 +0,0 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.search({
|
||||
body: {
|
||||
aggs: {
|
||||
genres: {
|
||||
terms: {
|
||||
script: {
|
||||
source: "doc['genre'].value",
|
||||
lang: 'painless'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
console.log(response)
|
||||
----
|
||||
|
||||
26
docs/doc_examples/033838729cfb5d1a28d04f69ee78d924.asciidoc
Normal file
26
docs/doc_examples/033838729cfb5d1a28d04f69ee78d924.asciidoc
Normal file
@ -0,0 +1,26 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.index({
|
||||
index: "example",
|
||||
document: {
|
||||
location: {
|
||||
type: "Polygon",
|
||||
orientation: "LEFT",
|
||||
coordinates: [
|
||||
[
|
||||
[-177, 10],
|
||||
[176, 15],
|
||||
[172, 0],
|
||||
[176, -15],
|
||||
[-177, -10],
|
||||
[-177, 10],
|
||||
],
|
||||
],
|
||||
},
|
||||
},
|
||||
});
|
||||
console.log(response);
|
||||
----
|
||||
36
docs/doc_examples/0350410d11579f4e876c798ce1eaef5b.asciidoc
Normal file
36
docs/doc_examples/0350410d11579f4e876c798ce1eaef5b.asciidoc
Normal file
@ -0,0 +1,36 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.index({
|
||||
index: "my-index-000001",
|
||||
id: 5,
|
||||
refresh: "true",
|
||||
document: {
|
||||
query: {
|
||||
bool: {
|
||||
should: [
|
||||
{
|
||||
match: {
|
||||
message: {
|
||||
query: "Japanese art",
|
||||
_name: "query1",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
match: {
|
||||
message: {
|
||||
query: "Holand culture",
|
||||
_name: "query2",
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
console.log(response);
|
||||
----
|
||||
38
docs/doc_examples/0350ff5ebb8207c004eb771088339cb4.asciidoc
Normal file
38
docs/doc_examples/0350ff5ebb8207c004eb771088339cb4.asciidoc
Normal file
@ -0,0 +1,38 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.search({
|
||||
index: "example-index",
|
||||
retriever: {
|
||||
rrf: {
|
||||
retrievers: [
|
||||
{
|
||||
standard: {
|
||||
query: {
|
||||
term: {
|
||||
text: "blue shoes sale",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
standard: {
|
||||
query: {
|
||||
sparse_vector: {
|
||||
field: "ml.tokens",
|
||||
inference_id: "my_elser_model",
|
||||
query: "What blue shoes are on sale?",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
rank_window_size: 50,
|
||||
rank_constant: 20,
|
||||
},
|
||||
},
|
||||
});
|
||||
console.log(response);
|
||||
----
|
||||
29
docs/doc_examples/03582fc93683e573062bcfda45e01d69.asciidoc
Normal file
29
docs/doc_examples/03582fc93683e573062bcfda45e01d69.asciidoc
Normal file
@ -0,0 +1,29 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.indices.create({
|
||||
index: "my-index-000001",
|
||||
settings: {
|
||||
analysis: {
|
||||
analyzer: {
|
||||
my_custom_analyzer: {
|
||||
type: "custom",
|
||||
tokenizer: "standard",
|
||||
char_filter: ["html_strip"],
|
||||
filter: ["lowercase", "asciifolding"],
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
console.log(response);
|
||||
|
||||
const response1 = await client.indices.analyze({
|
||||
index: "my-index-000001",
|
||||
analyzer: "my_custom_analyzer",
|
||||
text: "Is this déjà vu</b>?",
|
||||
});
|
||||
console.log(response1);
|
||||
----
|
||||
11
docs/doc_examples/035a7a919eb6513b4769a3727b7d6447.asciidoc
Normal file
11
docs/doc_examples/035a7a919eb6513b4769a3727b7d6447.asciidoc
Normal file
@ -0,0 +1,11 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.indices.analyze({
|
||||
analyzer: "whitespace",
|
||||
text: "The quick brown fox.",
|
||||
});
|
||||
console.log(response);
|
||||
----
|
||||
@ -0,0 +1,8 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.security.getServiceAccounts();
|
||||
console.log(response);
|
||||
----
|
||||
14
docs/doc_examples/03b1d76fa0b773d5b7d74ecb7e1e1a80.asciidoc
Normal file
14
docs/doc_examples/03b1d76fa0b773d5b7d74ecb7e1e1a80.asciidoc
Normal file
@ -0,0 +1,14 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.snapshot.restore({
|
||||
repository: "my_repository",
|
||||
snapshot: "my_snapshot_2099.05.06",
|
||||
indices: "my-index,logs-my_app-default",
|
||||
rename_pattern: "(.+)",
|
||||
rename_replacement: "restored-$1",
|
||||
});
|
||||
console.log(response);
|
||||
----
|
||||
11
docs/doc_examples/03c4b815bf1e6a8c5cfcc6ddf94bc093.asciidoc
Normal file
11
docs/doc_examples/03c4b815bf1e6a8c5cfcc6ddf94bc093.asciidoc
Normal file
@ -0,0 +1,11 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.sql.query({
|
||||
format: "txt",
|
||||
query: "SELECT * FROM library ORDER BY page_count DESC LIMIT 5",
|
||||
});
|
||||
console.log(response);
|
||||
----
|
||||
12
docs/doc_examples/04412d11783dac25b5fd2ec5407078a3.asciidoc
Normal file
12
docs/doc_examples/04412d11783dac25b5fd2ec5407078a3.asciidoc
Normal file
@ -0,0 +1,12 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.connector.updateApiKeyId({
|
||||
connector_id: "my-connector",
|
||||
api_key_id: "my-api-key-id",
|
||||
api_key_secret_id: "my-connector-secret-id",
|
||||
});
|
||||
console.log(response);
|
||||
----
|
||||
12
docs/doc_examples/044b2f99e7438e408685b258db17f863.asciidoc
Normal file
12
docs/doc_examples/044b2f99e7438e408685b258db17f863.asciidoc
Normal file
@ -0,0 +1,12 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.eql.search({
|
||||
index: "my-data-stream",
|
||||
query: '\n process where process.name == "regsvr32.exe"\n ',
|
||||
size: 50,
|
||||
});
|
||||
console.log(response);
|
||||
----
|
||||
52
docs/doc_examples/046b2249bbc49e77848c114cee940f17.asciidoc
Normal file
52
docs/doc_examples/046b2249bbc49e77848c114cee940f17.asciidoc
Normal file
@ -0,0 +1,52 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.search({
|
||||
index: "my-index",
|
||||
retriever: {
|
||||
rrf: {
|
||||
retrievers: [
|
||||
{
|
||||
standard: {
|
||||
query: {
|
||||
multi_match: {
|
||||
query: "How is the weather in Jamaica?",
|
||||
fields: ["title", "description"],
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
standard: {
|
||||
query: {
|
||||
text_expansion: {
|
||||
"ml.inference.title_expanded.predicted_value": {
|
||||
model_id: ".elser_model_2",
|
||||
model_text: "How is the weather in Jamaica?",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
standard: {
|
||||
query: {
|
||||
text_expansion: {
|
||||
"ml.inference.description_expanded.predicted_value": {
|
||||
model_id: ".elser_model_2",
|
||||
model_text: "How is the weather in Jamaica?",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
window_size: 10,
|
||||
rank_constant: 20,
|
||||
},
|
||||
},
|
||||
});
|
||||
console.log(response);
|
||||
----
|
||||
27
docs/doc_examples/0470d7101637568b9d3d1239f06325a7.asciidoc
Normal file
27
docs/doc_examples/0470d7101637568b9d3d1239f06325a7.asciidoc
Normal file
@ -0,0 +1,27 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.transport.request({
|
||||
method: "PUT",
|
||||
path: "/_internal/desired_nodes/<history_id>/<version>",
|
||||
body: {
|
||||
nodes: [
|
||||
{
|
||||
settings: {
|
||||
"node.name": "instance-000187",
|
||||
"node.external_id": "instance-000187",
|
||||
"node.roles": ["data_hot", "master"],
|
||||
"node.attr.data": "hot",
|
||||
"node.attr.logical_availability_zone": "zone-0",
|
||||
},
|
||||
processors: 8,
|
||||
memory: "58gb",
|
||||
storage: "2tb",
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
console.log(response);
|
||||
----
|
||||
@ -4,20 +4,14 @@
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.search({
|
||||
body: {
|
||||
query: {
|
||||
multi_match: {
|
||||
query: 'Will Smith',
|
||||
type: 'cross_fields',
|
||||
fields: [
|
||||
'first_name',
|
||||
'last_name'
|
||||
],
|
||||
operator: 'and'
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
console.log(response)
|
||||
query: {
|
||||
multi_match: {
|
||||
query: "Will Smith",
|
||||
type: "cross_fields",
|
||||
fields: ["first_name", "last_name"],
|
||||
operator: "and",
|
||||
},
|
||||
},
|
||||
});
|
||||
console.log(response);
|
||||
----
|
||||
|
||||
|
||||
10
docs/doc_examples/048652b6abfe195da8ea8cef10ee01b1.asciidoc
Normal file
10
docs/doc_examples/048652b6abfe195da8ea8cef10ee01b1.asciidoc
Normal file
@ -0,0 +1,10 @@
|
||||
// This file is autogenerated, DO NOT EDIT
|
||||
// Use `node scripts/generate-docs-examples.js` to generate the docs examples
|
||||
|
||||
[source, js]
|
||||
----
|
||||
const response = await client.transform.resetTransform({
|
||||
transform_id: "ecommerce_transform",
|
||||
});
|
||||
console.log(response);
|
||||
----
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user