Compare commits

...

21 Commits

Author SHA1 Message Date
1ef1754623 Bump to 8.16.2 (#2489) 2024-11-21 10:38:16 -06:00
be2fe317f2 [Backport 8.16] Ignore tap artifacts (#2492)
Co-authored-by: Josh Mock <joshua.mock@elastic.co>
2024-11-21 10:22:26 -06:00
1d2d934b50 Bump to 8.16.1 (#2478) 2024-11-18 12:45:53 -06:00
d0f5ada03d [Backport 8.16] Fix ECMAScript import (#2477) 2024-11-18 12:27:10 -06:00
47de886973 Auto-generated code for 8.16 (#2470) 2024-11-18 11:27:50 -06:00
1e103baec1 Bump version to 8.16.0 (#2464) 2024-11-14 11:50:48 -06:00
7d5f622506 Backport ts-standard upgrade (#2462) 2024-11-13 11:15:54 -06:00
8377b58af3 [Backport 8.16] Address feedback and add clarity (#2452)
Co-authored-by: Marci W <333176+marciw@users.noreply.github.com>
2024-11-12 11:07:38 -06:00
c150efbd21 Auto-generated code for 8.16 (#2442) 2024-11-11 11:04:42 -06:00
e7663aabde [Backport 8.16] Add changelog for 8.15.2 (#2446)
Co-authored-by: Josh Mock <joshua.mock@elastic.co>
2024-11-11 09:52:14 -06:00
c9615dc0ef [Backport 8.16] Add _id to the result of helpers.search (#2435)
Co-authored-by: Rami <72725910+ramikg@users.noreply.github.com>
2024-11-06 12:28:18 -06:00
bb5fb24d73 [Backport 8.16] Add streaming support to Arrow helper (#2430) 2024-11-04 16:20:06 -06:00
38358e20ab Auto-generated code for 8.16 (#2427) 2024-11-04 09:57:37 -06:00
9479d82644 Auto-generated code for 8.16 (#2410)
Co-authored-by: Josh Mock <joshua.mock@elastic.co>
2024-10-28 15:11:56 -05:00
18df52feb4 [Backport 8.16] Skip flaky test (#2419)
Co-authored-by: Josh Mock <joshua.mock@elastic.co>
2024-10-28 11:57:58 -05:00
f72f9e9a5a [Backport 8.16] Don't generate coverage during standard unit test run (#2406)
Co-authored-by: Josh Mock <joshua.mock@elastic.co>
2024-10-24 12:07:48 -05:00
c4151ceb35 [Backport 8.16] Upgrade tap to latest (#2401)
Co-authored-by: Josh Mock <joshua.mock@elastic.co>
2024-10-24 11:38:29 -05:00
f3aedc7ad0 Manual backport of #2375 (#2397) 2024-10-23 08:47:50 -05:00
586c42161d [Backport 8.16] Respect disablePrototypePoisoningProtection option (#2395)
Co-authored-by: Josh Mock <joshua.mock@elastic.co>
2024-10-22 15:03:23 -05:00
9947b0e365 [Backport 8.16] Add doc about timeout best practices (#2393)
Co-authored-by: Josh Mock <joshua.mock@elastic.co>
2024-10-22 15:01:15 -05:00
52b7264b45 [Backport 8.16] Update changelog for 8.15.1 (#2392)
Co-authored-by: Josh Mock <joshua.mock@elastic.co>
2024-10-22 15:00:57 -05:00
205 changed files with 3917 additions and 1125 deletions

View File

@ -6,7 +6,7 @@ steps:
env:
NODE_VERSION: "{{ matrix.nodejs }}"
TEST_SUITE: "{{ matrix.suite }}"
STACK_VERSION: 8.15.0
STACK_VERSION: 8.16.0
matrix:
setup:
suite:

View File

@ -5,3 +5,4 @@ elasticsearch
.git
lib
junit-output
.tap

View File

@ -1,18 +0,0 @@
name: Automerge
on:
pull_request_review:
types:
- submitted
jobs:
automerge:
runs-on: ubuntu-latest
if: github.event.review.state == 'approved'
steps:
- uses: reitermarkus/automerge@v2
with:
token: ${{ secrets.GH_TOKEN }}
merge-method: squash
pull-request-author-associations: OWNER
review-author-associations: OWNER,CONTRIBUTOR

View File

@ -12,6 +12,8 @@ jobs:
src-only: "${{ steps.changes.outputs.src-only }}"
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: dorny/paths-filter/@v3.0.2
id: changes
with:
@ -30,11 +32,13 @@ jobs:
strategy:
fail-fast: false
matrix:
node-version: [18.x, 20.x, 22.x]
node-version: [18.x, 20.x, 22.x, 23.x]
os: [ubuntu-latest, windows-latest, macOS-latest]
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
@ -53,12 +57,18 @@ jobs:
run: |
npm run test:unit
- name: ECMAScript module test
run: |
npm run test:esm
license:
name: License check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Use Node.js
uses: actions/setup-node@v4
@ -87,6 +97,8 @@ jobs:
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Use Bun
uses: oven-sh/setup-bun@v2
@ -103,6 +115,10 @@ jobs:
run: |
bun run test:unit-bun
- name: ECMAScript module test
run: |
bun run test:esm
auto-approve:
name: Auto-approve
needs: [test, license]

View File

@ -14,6 +14,7 @@ jobs:
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
ref: ${{ github.event.inputs.branch }}
- uses: actions/setup-node@v4
with:

View File

@ -28,12 +28,14 @@ jobs:
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
repository: elastic/elasticsearch-js
ref: main
path: stack
fetch-depth: 0
- uses: actions/checkout@v4
with:
persist-credentials: false
repository: elastic/elasticsearch-serverless-js
ref: main
path: serverless
@ -44,8 +46,8 @@ jobs:
with:
token: ${{ secrets.GH_TOKEN }}
path: serverless
title: 'Apply patch from elastic/elasticsearch-js#${{ github.event.pull_request.number }}'
commit-message: 'Apply patch from elastic/elasticsearch-js#${{ github.event.pull_request.number }}'
title: "Apply patch from elastic/elasticsearch-js#${{ github.event.pull_request.number }}"
commit-message: "Apply patch from elastic/elasticsearch-js#${{ github.event.pull_request.number }}"
body-path: /tmp/pr_body
draft: '${{ steps.apply-patch.outputs.PR_DRAFT }}'
add-paths: ':!*.rej'
draft: "${{ steps.apply-patch.outputs.PR_DRAFT }}"
add-paths: ":!*.rej"

3
.gitignore vendored
View File

@ -65,3 +65,6 @@ test/bundlers/parcel-test/.parcel-cache
lib
junit-output
bun.lockb
test-results
processinfo
.tap

View File

@ -73,3 +73,4 @@ CONTRIBUTING.md
src
bun.lockb
.tap

View File

@ -252,8 +252,8 @@ const client = new Client({
----
|`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`
|`boolean`, `'proto'`, `'constructor'` - The client can 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 about this security concern. If needed, you can enable prototype poisoning protection entirely (`false`) or one of the two checks (`'proto'` or `'constructor'`). For performance reasons, it is disabled by default. Read the `secure-json-parse` https://github.com/fastify/secure-json-parse[documentation] to learn more. +
_Default:_ `true`
|`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. +

View File

@ -1,6 +1,96 @@
[[changelog-client]]
== Release notes
[discrete]
=== 8.16.2
[discrete]
==== Fixes
[discrete]
===== Improved support for Elasticsearch `v8.16`
Updated TypeScript types based on fixes and improvements to the Elasticsearch specification.
[discrete]
===== Drop testing artifacts from npm package
Tap, the unit testing tool used by this project, was recently upgraded and started writing to a `.tap` directory. Since tests are run prior to an `npm publish` in CI, this directory was being included in the published package and bloating its size.
[discrete]
=== 8.16.1
[discrete]
==== Fixes
[discrete]
===== Fix ECMAScript imports
Fixed package configuration to correctly support native ECMAScript `import` syntax.
[discrete]
=== 8.16.0
[discrete]
==== Features
[discrete]
===== Support for Elasticsearch `v8.16`
You can find all the API changes
https://www.elastic.co/guide/en/elasticsearch/reference/8.16/release-notes-8.16.0.html[here].
[discrete]
===== Support Apache Arrow in ES|QL helper
The ES|QL helper can now return results as an Apache Arrow `Table` or `RecordBatchReader`, which enables high-performance calculations on ES|QL results, even if the response data is larger than the system's available memory. See <<esql-helper>> for more information.
[discrete]
==== Fixes
[discrete]
===== Pass prototype poisoning options to serializer correctly
The client's `disablePrototypePoisoningProtection` option was set to `true` by default, but when it was set to any other value it was ignored, making it impossible to enable prototype poisoning protection without providing a custom serializer implementation.
[discrete]
=== 8.15.3
[discrete]
==== Fixes
[discrete]
===== Improved support for Elasticsearch `v8.15`
Updated TypeScript types based on fixes and improvements to the Elasticsearch specification.
[discrete]
===== Drop testing artifacts from npm package
Tap, the unit testing tool, was recently upgraded and started writing to a `.tap` directory. Since tests are run prior to an `npm publish` in CI, this directory was being included in the published package and bloating its size.
[discrete]
=== 8.15.2
[discrete]
==== Fixes
[discrete]
===== Improved support for Elasticsearch `v8.15`
Updated TypeScript types based on fixes and improvements to the Elasticsearch specification.
[discrete]
=== 8.15.1
[discrete]
==== Fixes
[discrete]
===== Improved support for Elasticsearch `v8.15`
Updated TypeScript types based on fixes and improvements to the Elasticsearch specification.
[discrete]
=== 8.15.0

View File

@ -2,10 +2,11 @@
== Configuration
The client is designed to be easily configured for your needs. In the following
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>>
* <<timeout-best-practices>>
* <<child>>
* <<client-testing>>

View File

@ -1,7 +1,7 @@
[[client-connecting]]
== Connecting
== Connecting
This page contains the information you need to connect and use the Client with
This page contains the information you need to connect and use the Client with
{es}.
**On this page**
@ -19,7 +19,7 @@ This page contains the information you need to connect and use the Client with
[discrete]
=== Authentication
This document contains code snippets to show you how to connect to various {es}
This document contains code snippets to show you how to connect to various {es}
providers.
@ -27,18 +27,18 @@ providers.
[[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
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
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
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.
@ -61,18 +61,18 @@ const client = new Client({
[[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
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}]
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
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]
@ -90,24 +90,24 @@ below in the output from {es} (you may have to scroll up if it's been a while):
----
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
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
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()`]
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]
@ -152,7 +152,7 @@ const client = new Client({
})
----
The certificate fingerprint can be calculated using `openssl x509` with the
The certificate fingerprint can be calculated using `openssl x509` with the
certificate file:
[source,sh]
@ -160,8 +160,8 @@ certificate file:
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
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]
@ -186,8 +186,8 @@ SHA256 Fingerprint=A5:2D:D9:35:11:E8:C6:04:5E:21:F1:66:54:B7:7C:9E:E0:F3:4A:EA:2
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]
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]
@ -208,14 +208,14 @@ Following you can find all the supported authentication strategies.
[[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
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
NOTE: If you provide both basic authentication credentials and the ApiKey
configuration, the ApiKey takes precedence.
[source,js]
@ -268,10 +268,10 @@ const client = new Client({
[[auth-basic]]
==== Basic authentication
You can provide your credentials by passing the `username` and `password`
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
NOTE: If you provide both basic authentication credentials and the Api Key
configuration, the Api Key will take precedence.
[source,js]
@ -342,14 +342,14 @@ const result = await client.search({
}, { meta: true })
----
In this case, the result will be:
In this case, the result will be:
[source,ts]
----
{
body: object | boolean
statusCode: number
headers: object
warnings: [string],
warnings: string[],
meta: object
}
----
@ -361,7 +361,7 @@ NOTE: The body is a boolean value when you use `HEAD` APIs.
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
CAUTION: If you abort a request, the request will fail with a
`RequestAbortedError`.
@ -410,19 +410,23 @@ The supported request specific options are:
[cols=2*]
|===
|`ignore`
|`[number]` - HTTP status codes which should not be considered errors for this request. +
|`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. +
|`number | string` - Max request timeout for the request in milliseconds, it overrides the client default. +
_Default:_ `30000`
|`retryOnTimeout`
|`boolean` - Retry requests that have timed out.
_Default:_ `false`
|`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. +
|`string | boolean` - Enables body compression for the request. +
_Options:_ `false`, `'gzip'` +
_Default:_ `false`
@ -446,6 +450,10 @@ _Default:_ `null`
|`any` - Custom object per request. _(you can use it to pass data to the clients events)_ +
_Default:_ `null`
|`opaqueId`
|`string` - Set the `X-Opaque-Id` HTTP header. See {ref}/api-conventions.html#x-opaque-id
_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`
@ -458,6 +466,17 @@ _Default:_ `null`
|`AbortSignal` - The AbortSignal instance to allow request abortion. +
_Default:_ `null`
|`meta`
|`boolean` - Rather than returning the body, return an object containing `body`, `statusCode`, `headers` and `meta` keys +
_Default_: `false`
|`redaction`
|`object` - Options for redacting potentially sensitive data from error metadata. See <<redaction>>.
|`retryBackoff`
|`(min: number, max: number, attempt: number) => number;` - A function that calculates how long to sleep, in seconds, before the next request retry +
_Default:_ A built-in function that uses exponential backoff with jitter.
|===
[discrete]
@ -537,8 +556,8 @@ Resources used to assess these recommendations:
~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
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.
@ -715,5 +734,5 @@ This pre-flight product check allows the client to establish the version of Elas
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
Once the product check completes, no further product check HTTP requests are sent for
subsequent API calls.

View File

@ -5,10 +5,16 @@
----
const response = await client.indices.create({
index: "idx",
mappings: {
_source: {
mode: "synthetic",
settings: {
index: {
mapping: {
source: {
mode: "synthetic",
},
},
},
},
mappings: {
properties: {
kwd: {
type: "keyword",

View File

@ -3,8 +3,6 @@
[source, js]
----
const response = await client.cluster.reroute({
metric: "none",
});
const response = await client.cluster.reroute();
console.log(response);
----

View File

@ -8,6 +8,7 @@ const response = await client.esql.asyncQuery({
body: {
query:
"\n FROM my-index-000001,cluster_one:my-index-000001,cluster_two:my-index*\n | STATS COUNT(http.response.status_code) BY user.id\n | LIMIT 2\n ",
include_ccs_metadata: true,
},
});
console.log(response);

View 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.search({
index: "cooking_blog",
query: {
match: {
title: {
query: "fluffy pancakes breakfast",
minimum_should_match: 2,
},
},
},
});
console.log(response);
----

View File

@ -9,7 +9,7 @@ const response = await client.connector.put({
name: "My Connector",
description: "My Connector to sync data to Elastic index from Google Drive",
service_type: "google_drive",
language: "english",
language: "en",
});
console.log(response);
----

View 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.inference.put({
task_type: "text_embedding",
inference_id: "watsonx-embeddings",
inference_config: {
service: "watsonxai",
service_settings: {
api_key: "<api_key>",
url: "<url>",
model_id: "ibm/slate-30m-english-rtrvr",
project_id: "<project_id>",
api_version: "2024-03-14",
},
},
});
console.log(response);
----

View 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.search({
index: "my-index-bit-vectors",
query: {
script_score: {
query: {
match_all: {},
},
script: {
source: "dotProduct(params.query_vector, 'my_dense_vector')",
params: {
query_vector: [
0.23, 1.45, 3.67, 4.89, -0.56, 2.34, 3.21, 1.78, -2.45, 0.98, -0.12,
3.45, 4.56, 2.78, 1.23, 0.67, 3.89, 4.12, -2.34, 1.56, 0.78, 3.21,
4.12, 2.45, -1.67, 0.34, -3.45, 4.56, -2.78, 1.23, -0.67, 3.89,
-4.34, 2.12, -1.56, 0.78, -3.21, 4.45, 2.12, 1.67,
],
},
},
},
},
});
console.log(response);
----

View File

@ -0,0 +1,55 @@
// 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: "cooking_blog",
query: {
bool: {
must: [
{
term: {
"category.keyword": "Main Course",
},
},
{
term: {
tags: "vegetarian",
},
},
{
range: {
rating: {
gte: 4.5,
},
},
},
],
should: [
{
multi_match: {
query: "curry spicy",
fields: ["title^2", "description"],
},
},
{
range: {
date: {
gte: "now-1M/d",
},
},
},
],
must_not: [
{
term: {
"category.keyword": "Dessert",
},
},
],
},
},
});
console.log(response);
----

View File

@ -1,11 +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.transport.request({
method: "DELETE",
path: "/_ingest/geoip/database/my-database-id",
});
console.log(response);
----

View 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.index({
index: "mv",
refresh: "true",
document: {
a: [2, null, 1],
},
});
console.log(response);
const response1 = await client.esql.query({
query: "FROM mv | LIMIT 1",
});
console.log(response1);
----

View File

@ -5,7 +5,7 @@
----
const response = await client.ingest.putPipeline({
id: "geoip",
description: "Add geoip info",
description: "Add ip geolocation info",
processors: [
{
geoip: {

View File

@ -5,10 +5,16 @@
----
const response = await client.indices.create({
index: "idx",
mappings: {
_source: {
mode: "synthetic",
settings: {
index: {
mapping: {
source: {
mode: "synthetic",
},
},
},
},
mappings: {
properties: {
card: {
type: "wildcard",

View File

@ -0,0 +1,77 @@
// 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: {
attributes: {
type: "passthrough",
priority: 10,
properties: {
id: {
type: "keyword",
},
},
},
},
},
});
console.log(response);
const response1 = await client.index({
index: "my-index-000001",
id: 1,
document: {
attributes: {
id: "foo",
zone: 10,
},
},
});
console.log(response1);
const response2 = await client.search({
index: "my-index-000001",
query: {
bool: {
must: [
{
match: {
id: "foo",
},
},
{
match: {
zone: 10,
},
},
],
},
},
});
console.log(response2);
const response3 = await client.search({
index: "my-index-000001",
query: {
bool: {
must: [
{
match: {
"attributes.id": "foo",
},
},
{
match: {
"attributes.zone": 10,
},
},
],
},
},
});
console.log(response3);
----

View File

@ -0,0 +1,43 @@
// 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",
retriever: {
rule: {
match_criteria: {
query_string: "puggles",
user_country: "us",
},
ruleset_ids: ["my-ruleset"],
retriever: {
rrf: {
retrievers: [
{
standard: {
query: {
query_string: {
query: "pugs",
},
},
},
},
{
standard: {
query: {
query_string: {
query: "puggles",
},
},
},
},
],
},
},
},
},
});
console.log(response);
----

View File

@ -5,7 +5,7 @@
----
const response = await client.ingest.putPipeline({
id: "geoip",
description: "Add geoip info",
description: "Add ip geolocation info",
processors: [
{
geoip: {

View 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.indices.create({
index: "my-index-bit-vectors",
mappings: {
properties: {
my_dense_vector: {
type: "dense_vector",
index: false,
element_type: "bit",
dims: 40,
},
},
},
});
console.log(response);
const response1 = await client.index({
index: "my-index-bit-vectors",
id: 1,
document: {
my_dense_vector: [8, 5, -15, 1, -7],
},
});
console.log(response1);
const response2 = await client.index({
index: "my-index-bit-vectors",
id: 2,
document: {
my_dense_vector: [-1, 115, -3, 4, -128],
},
});
console.log(response2);
const response3 = await client.index({
index: "my-index-bit-vectors",
id: 3,
document: {
my_dense_vector: [2, 18, -5, 0, -124],
},
});
console.log(response3);
const response4 = await client.indices.refresh({
index: "my-index-bit-vectors",
});
console.log(response4);
----

View File

@ -29,6 +29,7 @@ const response = await client.indices.create({
"arabic_normalization",
"persian_normalization",
"persian_stop",
"persian_stem",
],
},
},

View File

@ -1,11 +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.transport.request({
method: "GET",
path: "/_ingest/geoip/database/my-database-id",
});
console.log(response);
----

View 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.index({
index: "amazon-reviews",
id: 1,
document: {
review_text:
"This product is lifechanging! I'm telling all my friends about it.",
review_vector: [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8],
},
});
console.log(response);
----

View 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({
index: "my-index-bit-vectors",
query: {
script_score: {
query: {
match_all: {},
},
script: {
source: "dotProduct(params.query_vector, 'my_dense_vector')",
params: {
query_vector: [8, 5, -15, 1, -7],
},
},
},
},
});
console.log(response);
----

View File

@ -0,0 +1,42 @@
// 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: 1,
refresh: "true",
document: {
text: "quick brown fox",
},
});
console.log(response);
const response1 = await client.index({
index: "my-index-000001",
id: 2,
refresh: "true",
document: {
text: "quick fox",
},
});
console.log(response1);
const response2 = await client.search({
index: "my-index-000001",
query: {
script_score: {
query: {
match: {
text: "quick brown fox",
},
},
script: {
source: "_termStats.termFreq().getAverage()",
},
},
},
});
console.log(response2);
----

View 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.inference.streamInference({
task_type: "completion",
inference_id: "openai-completion",
body: {
input: "What is Elastic?",
},
});
console.log(response);
----

View File

@ -1,11 +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.transport.request({
method: "DELETE",
path: "/_ingest/geoip/database/example-database-id",
});
console.log(response);
----

View File

@ -0,0 +1,32 @@
// 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-000002",
mappings: {
properties: {
attributes: {
type: "passthrough",
priority: 10,
properties: {
id: {
type: "keyword",
},
},
},
"resource.attributes": {
type: "passthrough",
priority: 20,
properties: {
id: {
type: "keyword",
},
},
},
},
},
});
console.log(response);
----

View File

@ -5,10 +5,16 @@
----
const response = await client.indices.create({
index: "idx",
mappings: {
_source: {
mode: "synthetic",
settings: {
index: {
mapping: {
source: {
mode: "synthetic",
},
},
},
},
mappings: {
properties: {
agg_metric: {
type: "aggregate_metric_double",

View File

@ -5,10 +5,16 @@
----
const response = await client.indices.create({
index: "idx",
mappings: {
_source: {
mode: "synthetic",
settings: {
index: {
mapping: {
source: {
mode: "synthetic",
},
},
},
},
mappings: {
properties: {
my_range: {
type: "long_range",

View 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.search({
index: "cooking_blog",
query: {
range: {
date: {
gte: "2023-05-01",
lte: "2023-05-31",
},
},
},
});
console.log(response);
----

View File

@ -0,0 +1,22 @@
// 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: "semantic-embeddings",
mappings: {
properties: {
semantic_text: {
type: "semantic_text",
inference_id: "my-elser-endpoint",
},
content: {
type: "text",
copy_to: "semantic_text",
},
},
},
});
console.log(response);
----

View File

@ -8,6 +8,7 @@ const response = await client.esql.asyncQuery({
body: {
query:
"\n FROM cluster_one:my-index*,cluster_two:logs*\n | STATS COUNT(http.response.status_code) BY user.id\n | LIMIT 2\n ",
include_ccs_metadata: true,
},
});
console.log(response);

View 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.inference.put({
task_type: "sparse_embedding",
inference_id: "small_chunk_size",
inference_config: {
service: "elasticsearch",
service_settings: {
num_allocations: 1,
num_threads: 1,
},
chunking_settings: {
strategy: "sentence",
max_chunk_size: 100,
sentence_overlap: 0,
},
},
});
console.log(response);
----

View File

@ -4,12 +4,13 @@
[source, js]
----
const response = await client.indices.create({
index: "my-index-000002",
mappings: {
properties: {
datetime: {
type: "date",
format: "uuuu/MM/dd HH:mm:ss||uuuu/MM/dd||epoch_millis",
index: "idx",
settings: {
index: {
mapping: {
source: {
mode: "synthetic",
},
},
},
},

View File

@ -5,10 +5,16 @@
----
const response = await client.indices.create({
index: "idx",
mappings: {
_source: {
mode: "synthetic",
settings: {
index: {
mapping: {
source: {
mode: "synthetic",
},
},
},
},
mappings: {
properties: {
flattened: {
type: "flattened",

View File

@ -4,7 +4,7 @@
[source, js]
----
const response = await client.security.putRole({
name: "role_with_remote_indices",
name: "only_remote_access_role",
remote_indices: [
{
clusters: ["my_remote"],
@ -12,6 +12,12 @@ const response = await client.security.putRole({
privileges: ["read", "read_cross_cluster", "view_index_metadata"],
},
],
remote_cluster: [
{
clusters: ["my_remote"],
privileges: ["monitor_stats"],
},
],
});
console.log(response);
----

View File

@ -5,10 +5,16 @@
----
const response = await client.indices.create({
index: "idx",
mappings: {
_source: {
mode: "synthetic",
settings: {
index: {
mapping: {
source: {
mode: "synthetic",
},
},
},
},
mappings: {
properties: {
text: {
type: "text",

View File

@ -5,10 +5,16 @@
----
const response = await client.indices.create({
index: "idx",
mappings: {
_source: {
mode: "synthetic",
settings: {
index: {
mapping: {
source: {
mode: "synthetic",
},
},
},
},
mappings: {
properties: {
versions: {
type: "version",

View File

@ -4,7 +4,6 @@
[source, js]
----
const response = await client.cluster.reroute({
metric: "none",
commands: [
{
allocate_empty_primary: {

View 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.bulk({
operations: [
{
index: {
_index: "amazon-reviews",
_id: "2",
},
},
{
review_text: "This product is amazing! I love it.",
review_vector: [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8],
},
{
index: {
_index: "amazon-reviews",
_id: "3",
},
},
{
review_text: "This product is terrible. I hate it.",
review_vector: [0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1],
},
{
index: {
_index: "amazon-reviews",
_id: "4",
},
},
{
review_text: "This product is great. I can do anything with it.",
review_vector: [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8],
},
{
index: {
_index: "amazon-reviews",
_id: "5",
},
},
{
review_text:
"This product has ruined my life and the lives of my family and friends.",
review_vector: [0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1],
},
],
});
console.log(response);
----

View 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.search({
index: "cooking_blog",
query: {
match: {
description: {
query: "fluffy pancakes",
operator: "and",
},
},
},
});
console.log(response);
----

View File

@ -0,0 +1,49 @@
// 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-metrics",
index_patterns: ["metrics-mymetrics-*"],
priority: 200,
data_stream: {},
template: {
settings: {
"index.mode": "time_series",
},
mappings: {
properties: {
attributes: {
type: "passthrough",
priority: 10,
time_series_dimension: true,
properties: {
"host.name": {
type: "keyword",
},
},
},
cpu: {
type: "integer",
time_series_metric: "counter",
},
},
},
},
});
console.log(response);
const response1 = await client.index({
index: "metrics-mymetrics-test",
document: {
"@timestamp": "2020-01-01T00:00:00.000Z",
attributes: {
"host.name": "foo",
zone: "bar",
},
cpu: 10,
},
});
console.log(response1);
----

View File

@ -1,23 +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.indices.updateAliases({
actions: [
{
remove: {
index: "my-index-000001",
alias: "my-index",
},
},
{
add: {
index: "my-index-000002",
alias: "my-index",
},
},
],
});
console.log(response);
----

View 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.inference.put({
task_type: "sparse_embedding",
inference_id: "my-elser-model",
inference_config: {
service: "elasticsearch",
service_settings: {
adaptive_allocations: {
enabled: true,
min_number_of_allocations: 1,
max_number_of_allocations: 10,
},
num_threads: 1,
model_id: ".elser_model_2",
},
},
});
console.log(response);
----

View File

@ -5,10 +5,16 @@
----
const response = await client.indices.create({
index: "idx",
mappings: {
_source: {
mode: "synthetic",
settings: {
index: {
mapping: {
source: {
mode: "synthetic",
},
},
},
},
mappings: {
properties: {
flattened: {
type: "flattened",

View 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.search({
index: "amazon-reviews",
retriever: {
knn: {
field: "review_vector",
query_vector: [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8],
k: 2,
num_candidates: 5,
},
},
});
console.log(response);
----

View 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: "cooking_blog",
query: {
match: {
description: {
query: "fluffy pancakes",
},
},
},
});
console.log(response);
----

View File

@ -0,0 +1,34 @@
// 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: "ip_location",
description: "Add ip geolocation info",
processors: [
{
ip_location: {
field: "ip",
},
},
],
});
console.log(response);
const response1 = await client.index({
index: "my-index-000001",
id: "my_id",
pipeline: "ip_location",
document: {
ip: "80.231.5.0",
},
});
console.log(response1);
const response2 = await client.get({
index: "my-index-000001",
id: "my_id",
});
console.log(response2);
----

View File

@ -3,9 +3,10 @@
[source, js]
----
const response = await client.indices.putSettings({
index: ".watches",
settings: {
const response = await client.transport.request({
method: "PUT",
path: "/_watcher/settings",
body: {
"index.routing.allocation.include.role": "watcher",
},
});

View 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.search({
index: "movies",
retriever: {
rule: {
match_criteria: {
query_string: "harry potter",
},
ruleset_ids: ["my-ruleset"],
retriever: {
standard: {
query: {
query_string: {
query: "harry potter",
},
},
},
},
},
},
});
console.log(response);
----

View File

@ -3,9 +3,8 @@
[source, js]
----
const response = await client.snapshot.create({
repository: "my_repository",
snapshot: "_verify_integrity",
const response = await client.snapshot.repositoryVerifyIntegrity({
name: "my_repository",
});
console.log(response);
----

View File

@ -3,12 +3,12 @@
[source, js]
----
const response = await client.reindex({
source: {
index: "my-index-000001",
},
dest: {
index: "my-index-000002",
const response = await client.search({
index: "cooking_blog",
query: {
term: {
"author.keyword": "Maria Rodriguez",
},
},
});
console.log(response);

View File

@ -0,0 +1,42 @@
// 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: "movies",
retriever: {
rule: {
match_criteria: {
query_string: "harry potter",
},
ruleset_ids: ["my-ruleset"],
retriever: {
rrf: {
retrievers: [
{
standard: {
query: {
query_string: {
query: "sorcerer's stone",
},
},
},
},
{
standard: {
query: {
query_string: {
query: "chamber of secrets",
},
},
},
},
],
},
},
},
},
});
console.log(response);
----

View 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.inference.put({
task_type: "sparse_embedding",
inference_id: "use_existing_deployment",
inference_config: {
service: "elasticsearch",
service_settings: {
deployment_id: ".elser_model_2",
},
},
});
console.log(response);
----

View File

@ -5,10 +5,16 @@
----
const response = await client.indices.create({
index: "idx_keep",
mappings: {
_source: {
mode: "synthetic",
settings: {
index: {
mapping: {
source: {
mode: "synthetic",
},
},
},
},
mappings: {
properties: {
path: {
type: "object",

View File

@ -0,0 +1,61 @@
// 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: "cooking_blog",
properties: {
title: {
type: "text",
analyzer: "standard",
fields: {
keyword: {
type: "keyword",
ignore_above: 256,
},
},
},
description: {
type: "text",
fields: {
keyword: {
type: "keyword",
},
},
},
author: {
type: "text",
fields: {
keyword: {
type: "keyword",
},
},
},
date: {
type: "date",
format: "yyyy-MM-dd",
},
category: {
type: "text",
fields: {
keyword: {
type: "keyword",
},
},
},
tags: {
type: "text",
fields: {
keyword: {
type: "keyword",
},
},
},
rating: {
type: "float",
},
},
});
console.log(response);
----

View 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.connector.put({
connector_id: "my-{service-name-stub}-connector",
index_name: "my-elasticsearch-index",
name: "Content synced from {service-name}",
service_type: "{service-name-stub}",
});
console.log(response);
----

View File

@ -0,0 +1,35 @@
// 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: "semantic-embeddings",
retriever: {
rrf: {
retrievers: [
{
standard: {
query: {
match: {
content: "How to avoid muscle soreness while running?",
},
},
},
},
{
standard: {
query: {
semantic: {
field: "semantic_text",
query: "How to avoid muscle soreness while running?",
},
},
},
},
],
},
},
});
console.log(response);
----

View File

@ -4,7 +4,6 @@
[source, js]
----
const response = await client.cluster.reroute({
metric: "none",
commands: [
{
move: {

View File

@ -5,10 +5,16 @@
----
const response = await client.indices.create({
index: "idx",
mappings: {
_source: {
mode: "synthetic",
settings: {
index: {
mapping: {
source: {
mode: "synthetic",
},
},
},
},
mappings: {
properties: {
flattened: {
type: "flattened",

View File

@ -5,10 +5,16 @@
----
const response = await client.indices.create({
index: "idx",
mappings: {
_source: {
mode: "synthetic",
settings: {
index: {
mapping: {
source: {
mode: "synthetic",
},
},
},
},
mappings: {
properties: {
my_range: {
type: "long_range",

View File

@ -0,0 +1,34 @@
// 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: "ip_location",
description: "Add ip geolocation info",
processors: [
{
ip_location: {
field: "ip",
},
},
],
});
console.log(response);
const response1 = await client.index({
index: "my-index-000001",
id: "my_id",
pipeline: "ip_location",
document: {
ip: "89.160.20.128",
},
});
console.log(response1);
const response2 = await client.get({
index: "my-index-000001",
id: "my_id",
});
console.log(response2);
----

View File

@ -5,10 +5,16 @@
----
const response = await client.indices.create({
index: "idx",
mappings: {
_source: {
mode: "synthetic",
settings: {
index: {
mapping: {
source: {
mode: "synthetic",
},
},
},
},
mappings: {
properties: {
date: {
type: "date_nanos",

View File

@ -5,10 +5,16 @@
----
const response = await client.indices.create({
index: "idx",
mappings: {
_source: {
mode: "synthetic",
settings: {
index: {
mapping: {
source: {
mode: "synthetic",
},
},
},
},
mappings: {
properties: {
bool: {
type: "boolean",

View File

@ -5,10 +5,16 @@
----
const response = await client.indices.create({
index: "idx",
mappings: {
_source: {
mode: "synthetic",
settings: {
index: {
mapping: {
source: {
mode: "synthetic",
},
},
},
},
mappings: {
properties: {
my_range: {
type: "integer_range",

View 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.search({
index: "cooking_blog",
query: {
bool: {
filter: [
{
term: {
"category.keyword": "Breakfast",
},
},
],
},
},
});
console.log(response);
----

View File

@ -5,10 +5,16 @@
----
const response = await client.indices.create({
index: "idx",
mappings: {
_source: {
mode: "synthetic",
settings: {
index: {
mapping: {
source: {
mode: "synthetic",
},
},
},
},
mappings: {
properties: {
f: {
type: "scaled_float",

View File

@ -5,10 +5,16 @@
----
const response = await client.indices.create({
index: "idx",
mappings: {
_source: {
mode: "synthetic",
settings: {
index: {
mapping: {
source: {
mode: "synthetic",
},
},
},
},
mappings: {
properties: {
my_range: {
type: "date_range",

View File

@ -5,11 +5,15 @@
----
const response = await client.search({
index: "my-index-000001",
query: {
retriever: {
rule: {
organic: {
query_string: {
query: "puggles",
retriever: {
standard: {
query: {
query_string: {
query: "puggles",
},
},
},
},
match_criteria: {

View 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: "cooking_blog",
query: {
multi_match: {
query: "vegetarian curry",
fields: ["title^3", "description^2", "tags"],
},
},
});
console.log(response);
----

View 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.connector.put({
connector_id: "my-{service-name-stub}-connector",
index_name: "my-elasticsearch-index",
name: "Content synced from {service-name}",
service_type: "{service-name-stub}",
is_native: true,
});
console.log(response);
----

View File

@ -5,7 +5,7 @@
----
const response = await client.ingest.putPipeline({
id: "geoip",
description: "Add geoip info",
description: "Add ip geolocation info",
processors: [
{
geoip: {

View File

@ -5,10 +5,16 @@
----
const response = await client.indices.create({
index: "idx",
mappings: {
_source: {
mode: "synthetic",
settings: {
index: {
mapping: {
source: {
mode: "synthetic",
},
},
},
},
mappings: {
properties: {
point: {
type: "geo_point",

View File

@ -5,10 +5,16 @@
----
const response = await client.indices.create({
index: "idx",
mappings: {
_source: {
mode: "synthetic",
settings: {
index: {
mapping: {
source: {
mode: "synthetic",
},
},
},
},
mappings: {
properties: {
long: {
type: "long",

View File

@ -5,10 +5,16 @@
----
const response = await client.indices.create({
index: "idx",
mappings: {
_source: {
mode: "synthetic",
settings: {
index: {
mapping: {
source: {
mode: "synthetic",
},
},
},
},
mappings: {
properties: {
binary: {
type: "binary",

View File

@ -3,10 +3,14 @@
[source, js]
----
const response = await client.indices.putSettings({
const response = await client.index({
index: "my-index-000001",
settings: {
"index.merge.policy.max_merge_at_once_explicit": null,
id: 1,
document: {
attributes: {
id: "foo",
},
id: "bar",
},
});
console.log(response);

View File

@ -5,10 +5,16 @@
----
const response = await client.indices.create({
index: "idx",
mappings: {
_source: {
mode: "synthetic",
settings: {
index: {
mapping: {
source: {
mode: "synthetic",
},
},
},
},
mappings: {
properties: {
date: {
type: "date",

View File

@ -0,0 +1,88 @@
// 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.bulk({
index: "cooking_blog",
refresh: "wait_for",
operations: [
{
index: {
_id: "1",
},
},
{
title: "Perfect Pancakes: A Fluffy Breakfast Delight",
description:
"Learn the secrets to making the fluffiest pancakes, so amazing you won't believe your tastebuds. This recipe uses buttermilk and a special folding technique to create light, airy pancakes that are perfect for lazy Sunday mornings.",
author: "Maria Rodriguez",
date: "2023-05-01",
category: "Breakfast",
tags: ["pancakes", "breakfast", "easy recipes"],
rating: 4.8,
},
{
index: {
_id: "2",
},
},
{
title: "Spicy Thai Green Curry: A Vegetarian Adventure",
description:
"Dive into the flavors of Thailand with this vibrant green curry. Packed with vegetables and aromatic herbs, this dish is both healthy and satisfying. Don't worry about the heat - you can easily adjust the spice level to your liking.",
author: "Liam Chen",
date: "2023-05-05",
category: "Main Course",
tags: ["thai", "vegetarian", "curry", "spicy"],
rating: 4.6,
},
{
index: {
_id: "3",
},
},
{
title: "Classic Beef Stroganoff: A Creamy Comfort Food",
description:
"Indulge in this rich and creamy beef stroganoff. Tender strips of beef in a savory mushroom sauce, served over a bed of egg noodles. It's the ultimate comfort food for chilly evenings.",
author: "Emma Watson",
date: "2023-05-10",
category: "Main Course",
tags: ["beef", "pasta", "comfort food"],
rating: 4.7,
},
{
index: {
_id: "4",
},
},
{
title: "Vegan Chocolate Avocado Mousse",
description:
"Discover the magic of avocado in this rich, vegan chocolate mousse. Creamy, indulgent, and secretly healthy, it's the perfect guilt-free dessert for chocolate lovers.",
author: "Alex Green",
date: "2023-05-15",
category: "Dessert",
tags: ["vegan", "chocolate", "avocado", "healthy dessert"],
rating: 4.5,
},
{
index: {
_id: "5",
},
},
{
title: "Crispy Oven-Fried Chicken",
description:
"Get that perfect crunch without the deep fryer! This oven-fried chicken recipe delivers crispy, juicy results every time. A healthier take on the classic comfort food.",
author: "Maria Rodriguez",
date: "2023-05-20",
category: "Main Course",
tags: ["chicken", "oven-fried", "healthy"],
rating: 4.9,
},
],
});
console.log(response);
----

View 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: "cooking_blog",
query: {
multi_match: {
query: "vegetarian curry",
fields: ["title", "description", "tags"],
},
},
});
console.log(response);
----

View File

@ -5,10 +5,16 @@
----
const response = await client.indices.create({
index: "idx",
mappings: {
_source: {
mode: "synthetic",
settings: {
index: {
mapping: {
source: {
mode: "synthetic",
},
},
},
},
mappings: {
properties: {
kwd: {
type: "keyword",

View 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.search({
index: "my-index",
size: 10,
knn: {
query_vector: [0.04283529, 0.85670587, -0.51402352, 0],
field: "my_int4_vector",
k: 20,
num_candidates: 50,
},
rescore: {
window_size: 20,
query: {
rescore_query: {
script_score: {
query: {
match_all: {},
},
script: {
source: "(dotProduct(params.queryVector, 'my_int4_vector') + 1.0)",
params: {
queryVector: [0.04283529, 0.85670587, -0.51402352, 0],
},
},
},
},
query_weight: 0,
rescore_query_weight: 1,
},
},
});
console.log(response);
----

View File

@ -5,10 +5,16 @@
----
const response = await client.indices.create({
index: "idx",
mappings: {
_source: {
mode: "synthetic",
settings: {
index: {
mapping: {
source: {
mode: "synthetic",
},
},
},
},
mappings: {
properties: {
ip: {
type: "ip",

View 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.indices.create({
index: "amazon-reviews",
mappings: {
properties: {
review_vector: {
type: "dense_vector",
dims: 8,
index: true,
similarity: "cosine",
},
review_text: {
type: "text",
},
},
},
});
console.log(response);
----

View File

@ -52,6 +52,20 @@ const response = await client.simulate.ingest({
},
},
},
index_template_substitutions: {
"my-index-template": {
index_patterns: ["my-index-*"],
composed_of: ["component_template_1", "component_template_2"],
},
},
mapping_addition: {
dynamic: "strict",
properties: {
foo: {
type: "keyword",
},
},
},
},
});
console.log(response);

View 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.search({
index: "my-index",
size: 10,
query: {
script_score: {
query: {
knn: {
query_vector: [0.04283529, 0.85670587, -0.51402352, 0],
field: "my_int4_vector",
num_candidates: 20,
},
},
script: {
source: "(dotProduct(params.queryVector, 'my_int4_vector') + 1.0)",
params: {
queryVector: [0.04283529, 0.85670587, -0.51402352, 0],
},
},
},
},
});
console.log(response);
----

View 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.inference.inference({
task_type: "my-inference-endpoint",
inference_id: "_update",
service_settings: {
api_key: "<API_KEY>",
},
});
console.log(response);
----

View File

@ -4,12 +4,11 @@
[source, js]
----
const response = await client.transport.request({
method: "PUT",
path: "/_ingest/geoip/database/my-database-id",
method: "POST",
path: "/_query_rules/my-ruleset/_test",
body: {
name: "GeoIP2-Domain",
maxmind: {
account_id: "1025402",
match_criteria: {
query_string: "puggles",
},
},
});

View 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.ingest.putPipeline({
id: "ip_location",
description: "Add ip geolocation info",
processors: [
{
ip_location: {
field: "ip",
target_field: "geo",
database_file: "GeoLite2-Country.mmdb",
},
},
],
});
console.log(response);
const response1 = await client.index({
index: "my-index-000001",
id: "my_id",
pipeline: "ip_location",
document: {
ip: "89.160.20.128",
},
});
console.log(response1);
const response2 = await client.get({
index: "my-index-000001",
id: "my_id",
});
console.log(response2);
----

View File

@ -0,0 +1,22 @@
// 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-byte-quantized-index",
mappings: {
properties: {
my_vector: {
type: "dense_vector",
dims: 64,
index: true,
index_options: {
type: "bbq_hnsw",
},
},
},
},
});
console.log(response);
----

View File

@ -4,12 +4,7 @@
[source, js]
----
const response = await client.indices.create({
index: "idx",
mappings: {
_source: {
mode: "synthetic",
},
},
index: "cooking_blog",
});
console.log(response);
----

View File

@ -5,7 +5,7 @@
----
const response = await client.cat.mlTrainedModels({
h: "c,o,l,ct,v",
v: "ture",
v: "true",
});
console.log(response);
----

Some files were not shown because too many files have changed in this diff Show More