mirror of
https://github.com/lowdefy/lowdefy.git
synced 2025-03-31 15:20:32 +08:00
Merge remote-tracking branch 'origin/v4' into build-transformer
This commit is contained in:
commit
ca4ac4e712
1
.pnp.cjs
generated
1
.pnp.cjs
generated
@ -5206,6 +5206,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) {
|
||||
["@lowdefy/blocks-loaders", "workspace:packages/plugins/blocks/blocks-loaders"],
|
||||
["@lowdefy/blocks-markdown", "workspace:packages/plugins/blocks/blocks-markdown"],
|
||||
["@lowdefy/connection-axios-http", "workspace:packages/plugins/connections/connection-axios-http"],
|
||||
["@lowdefy/connection-elasticsearch", "workspace:packages/plugins/connections/connection-elasticsearch"],
|
||||
["@lowdefy/connection-redis", "workspace:packages/plugins/connections/connection-redis"],
|
||||
["@lowdefy/helpers", "workspace:packages/utils/helpers"],
|
||||
["@lowdefy/node-utils", "workspace:packages/utils/node-utils"],
|
||||
|
@ -63,6 +63,7 @@
|
||||
"@lowdefy/blocks-loaders": "4.0.0-alpha.6",
|
||||
"@lowdefy/blocks-markdown": "4.0.0-alpha.6",
|
||||
"@lowdefy/connection-axios-http": "4.0.0-alpha.6",
|
||||
"@lowdefy/connection-elasticsearch": "4.0.0-alpha.6",
|
||||
"@lowdefy/connection-redis": "4.0.0-alpha.6",
|
||||
"@lowdefy/operators-change-case": "4.0.0-alpha.6",
|
||||
"@lowdefy/operators-diff": "4.0.0-alpha.6",
|
||||
|
@ -27,6 +27,7 @@ const defaultPackages = [
|
||||
'@lowdefy/blocks-loaders',
|
||||
'@lowdefy/blocks-markdown',
|
||||
'@lowdefy/connection-axios-http',
|
||||
'@lowdefy/connection-elasticsearch',
|
||||
'@lowdefy/connection-redis',
|
||||
'@lowdefy/operators-change-case',
|
||||
// '@lowdefy/operators-diff',
|
||||
|
@ -27,8 +27,8 @@
|
||||
},
|
||||
"type": "module",
|
||||
"exports": {
|
||||
".": "./dist/index.js",
|
||||
"./connections/*": "./dist/connections/*"
|
||||
"./connections": "./dist/connections.js",
|
||||
"./types": "./dist/types.js"
|
||||
},
|
||||
"files": [
|
||||
"dist/*"
|
||||
|
@ -14,13 +14,4 @@
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
export default {
|
||||
import: {
|
||||
path: 'connections/Elasticsearch/ElasticsearchIndex/ElasticsearchIndex.js',
|
||||
schema: 'connections/Elasticsearch/ElasticsearchIndex/ElasticsearchIndex.json',
|
||||
},
|
||||
meta: {
|
||||
checkRead: false,
|
||||
checkWrite: true,
|
||||
},
|
||||
};
|
||||
export { default as Elasticsearch } from './connections/Elasticsearch/Elasticsearch.js';
|
@ -20,11 +20,10 @@ import ElasticsearchIndex from './ElasticsearchIndex/ElasticsearchIndex.js';
|
||||
import ElasticsearchSearch from './ElasticsearchSearch/ElasticsearchSearch.js';
|
||||
import ElasticsearchUpdate from './ElasticsearchUpdate/ElasticsearchUpdate.js';
|
||||
import ElasticsearchUpdateByQuery from './ElasticsearchUpdateByQuery/ElasticsearchUpdateByQuery.js';
|
||||
import schema from './schema.js';
|
||||
|
||||
export default {
|
||||
import: {
|
||||
schema: 'connections/Elasticsearch/ElasticsearchSchema.json',
|
||||
},
|
||||
schema,
|
||||
requests: {
|
||||
ElasticsearchDelete,
|
||||
ElasticsearchDeleteByQuery,
|
||||
|
@ -16,7 +16,8 @@
|
||||
|
||||
import { validate } from '@lowdefy/ajv';
|
||||
import Elasticsearch from './Elasticsearch.js';
|
||||
import schema from './ElasticsearchSchema.json';
|
||||
|
||||
const schema = Elasticsearch.schema;
|
||||
|
||||
test('All requests are present', () => {
|
||||
expect(Elasticsearch.requests.ElasticsearchSearch).toBeDefined();
|
||||
|
@ -15,8 +15,9 @@
|
||||
*/
|
||||
|
||||
import { Client } from '@elastic/elasticsearch';
|
||||
import schema from './schema.js';
|
||||
|
||||
async function elasticsearchDelete({ request, connection }) {
|
||||
async function ElasticsearchDelete({ request, connection }) {
|
||||
const client = new Client(connection);
|
||||
|
||||
const { body: response } = await client.delete({
|
||||
@ -30,4 +31,10 @@ async function elasticsearchDelete({ request, connection }) {
|
||||
};
|
||||
}
|
||||
|
||||
export default elasticsearchDelete;
|
||||
ElasticsearchDelete.schema = schema;
|
||||
ElasticsearchDelete.meta = {
|
||||
checkRead: false,
|
||||
checkWrite: true,
|
||||
};
|
||||
|
||||
export default ElasticsearchDelete;
|
||||
|
@ -1,87 +0,0 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"title": "Lowdefy Request Schema - ElasticsearchDelete",
|
||||
"type": "object",
|
||||
"description": "Removes a JSON document from the specified index.",
|
||||
"required": [
|
||||
"id"
|
||||
],
|
||||
"properties": {
|
||||
"id": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"type": "number"
|
||||
}
|
||||
],
|
||||
"description": "Unique identifier for the document."
|
||||
},
|
||||
"index": {
|
||||
"type": "string",
|
||||
"description": "The name of the index."
|
||||
},
|
||||
"if_seq_no": {
|
||||
"type": "integer",
|
||||
"description": "Only perform the delete operation if the last operation that has changed the document has the specified sequence number."
|
||||
},
|
||||
"if_primary_term": {
|
||||
"type": "integer",
|
||||
"description": "Only perform the delete operation if the last operation that has changed the document has the specified primary term."
|
||||
},
|
||||
"refresh": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"type": "boolean"
|
||||
}
|
||||
],
|
||||
"description": "If true, Elasticsearch refreshes the affected shards to make this operation visible to search, if wait_for then wait for a refresh to make this operation visible to search, if false do nothing with refreshes. Valid values: true, false, wait_for. Default: false.",
|
||||
"enum": [
|
||||
"true",
|
||||
"false",
|
||||
true,
|
||||
false,
|
||||
"wait_for"
|
||||
],
|
||||
"default": false
|
||||
},
|
||||
"routing": {
|
||||
"description": "Custom value used to route operations to a specific shard.",
|
||||
"type": "string"
|
||||
},
|
||||
"timeout": {
|
||||
"type": "string",
|
||||
"description": "Period to wait for active shards. Defaults to 1m (one minute).",
|
||||
"default": "1m"
|
||||
},
|
||||
"version": {
|
||||
"description": "Explicit version number for concurrency control. The specified version must match the current version of the document for the request to succeed.",
|
||||
"type": "integer"
|
||||
},
|
||||
"version_type": {
|
||||
"type": "string",
|
||||
"description": "Specific version type.",
|
||||
"enum": [
|
||||
"internal",
|
||||
"external",
|
||||
"external_gte",
|
||||
"force"
|
||||
]
|
||||
},
|
||||
"wait_for_active_shards": {
|
||||
"type": "string",
|
||||
"description": "The number of shard copies that must be active before proceeding with the operation. Set to all or any positive integer up to the total number of shards in the index (number_of_replicas+1). Default: 1, the primary shard.",
|
||||
"default": "1"
|
||||
}
|
||||
},
|
||||
"errorMessage": {
|
||||
"type": "ElasticsearchDelete request properties should be an object.",
|
||||
"required": {
|
||||
"id": "ElasticsearchDelete request should have required property \"id\"."
|
||||
}
|
||||
}
|
||||
}
|
@ -16,11 +16,10 @@
|
||||
|
||||
import { Client } from '@elastic/elasticsearch';
|
||||
import { validate } from '@lowdefy/ajv';
|
||||
import elasticsearchDelete from './ElasticsearchDelete.js';
|
||||
import requestIndex from './index.js';
|
||||
import schema from './ElasticsearchDelete.json';
|
||||
import ElasticsearchDelete from './ElasticsearchDelete.js';
|
||||
|
||||
const { checkRead, checkWrite } = requestIndex.meta;
|
||||
const { checkRead, checkWrite } = ElasticsearchDelete.meta;
|
||||
const schema = ElasticsearchDelete.schema;
|
||||
|
||||
const mockElasticsearchClient = jest.fn(() => mockElasticsearchClient);
|
||||
mockElasticsearchClient.delete = jest.fn(() => mockElasticsearchClient);
|
||||
@ -78,7 +77,7 @@ test('ElasticsearchDelete', async () => {
|
||||
const request = {
|
||||
id: 42,
|
||||
};
|
||||
const res = await elasticsearchDelete({ request, connection });
|
||||
const res = await ElasticsearchDelete({ request, connection });
|
||||
expect(Client.mock.calls).toEqual([
|
||||
[
|
||||
{
|
||||
|
@ -0,0 +1,95 @@
|
||||
/*
|
||||
Copyright 2020-2021 Lowdefy, Inc
|
||||
|
||||
Licensed 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.
|
||||
*/
|
||||
|
||||
export default {
|
||||
$schema: 'http://json-schema.org/draft-07/schema#',
|
||||
title: 'Lowdefy Request Schema - ElasticsearchDelete',
|
||||
type: 'object',
|
||||
description: 'Removes a JSON document from the specified index.',
|
||||
required: ['id'],
|
||||
properties: {
|
||||
id: {
|
||||
anyOf: [
|
||||
{
|
||||
type: 'string',
|
||||
},
|
||||
{
|
||||
type: 'number',
|
||||
},
|
||||
],
|
||||
description: 'Unique identifier for the document.',
|
||||
},
|
||||
index: {
|
||||
type: 'string',
|
||||
description: 'The name of the index.',
|
||||
},
|
||||
if_seq_no: {
|
||||
type: 'integer',
|
||||
description:
|
||||
'Only perform the delete operation if the last operation that has changed the document has the specified sequence number.',
|
||||
},
|
||||
if_primary_term: {
|
||||
type: 'integer',
|
||||
description:
|
||||
'Only perform the delete operation if the last operation that has changed the document has the specified primary term.',
|
||||
},
|
||||
refresh: {
|
||||
anyOf: [
|
||||
{
|
||||
type: 'string',
|
||||
},
|
||||
{
|
||||
type: 'boolean',
|
||||
},
|
||||
],
|
||||
description:
|
||||
'If true, Elasticsearch refreshes the affected shards to make this operation visible to search, if wait_for then wait for a refresh to make this operation visible to search, if false do nothing with refreshes. Valid values: true, false, wait_for. Default: false.',
|
||||
enum: ['true', 'false', true, false, 'wait_for'],
|
||||
default: false,
|
||||
},
|
||||
routing: {
|
||||
description: 'Custom value used to route operations to a specific shard.',
|
||||
type: 'string',
|
||||
},
|
||||
timeout: {
|
||||
type: 'string',
|
||||
description: 'Period to wait for active shards. Defaults to 1m (one minute).',
|
||||
default: '1m',
|
||||
},
|
||||
version: {
|
||||
description:
|
||||
'Explicit version number for concurrency control. The specified version must match the current version of the document for the request to succeed.',
|
||||
type: 'integer',
|
||||
},
|
||||
version_type: {
|
||||
type: 'string',
|
||||
description: 'Specific version type.',
|
||||
enum: ['internal', 'external', 'external_gte', 'force'],
|
||||
},
|
||||
wait_for_active_shards: {
|
||||
type: 'string',
|
||||
description:
|
||||
'The number of shard copies that must be active before proceeding with the operation. Set to all or any positive integer up to the total number of shards in the index (number_of_replicas+1). Default: 1, the primary shard.',
|
||||
default: '1',
|
||||
},
|
||||
},
|
||||
errorMessage: {
|
||||
type: 'ElasticsearchDelete request properties should be an object.',
|
||||
required: {
|
||||
id: 'ElasticsearchDelete request should have required property "id".',
|
||||
},
|
||||
},
|
||||
};
|
@ -15,8 +15,9 @@
|
||||
*/
|
||||
|
||||
import { Client } from '@elastic/elasticsearch';
|
||||
import schema from './schema.js';
|
||||
|
||||
async function elasticsearchDeleteByQuery({ request, connection }) {
|
||||
async function ElasticsearchDeleteByQuery({ request, connection }) {
|
||||
const client = new Client(connection);
|
||||
|
||||
const { body: response } = await client.deleteByQuery({
|
||||
@ -29,4 +30,10 @@ async function elasticsearchDeleteByQuery({ request, connection }) {
|
||||
};
|
||||
}
|
||||
|
||||
export default elasticsearchDeleteByQuery;
|
||||
ElasticsearchDeleteByQuery.schema = schema;
|
||||
ElasticsearchDeleteByQuery.meta = {
|
||||
checkRead: false,
|
||||
checkWrite: true,
|
||||
};
|
||||
|
||||
export default ElasticsearchDeleteByQuery;
|
||||
|
@ -1,231 +0,0 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"title": "Lowdefy Request Schema - ElasticsearchDeleteByQuery",
|
||||
"type": "object",
|
||||
"description": "Deletes documents that match the specified query.",
|
||||
"properties": {
|
||||
"index": {
|
||||
"type": "string",
|
||||
"description": "The name of the index."
|
||||
},
|
||||
"allow_no_indices": {
|
||||
"type": "boolean",
|
||||
"description": "If false, the request returns an error if any wildcard expression, index alias, or _all value targets only missing or closed indices. This behavior applies even if the request targets other open indices. For example, a request targeting foo*,bar* returns an error if an index starts with foo but no index starts with bar.",
|
||||
"default": true
|
||||
},
|
||||
"analyzer": {
|
||||
"description": "The analyzer to use for the query string.",
|
||||
"type": "string"
|
||||
},
|
||||
"analyze_wildcard": {
|
||||
"description": "Specify whether wildcard and prefix queries should be analyzed.",
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"conflicts": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"abort",
|
||||
"proceed"
|
||||
],
|
||||
"description": "What to do if delete by query hits version conflicts: abort or proceed. Defaults to abort.",
|
||||
"default": "abort"
|
||||
},
|
||||
"default_operator": {
|
||||
"description": "The default operator for query string query (AND or OR).",
|
||||
"enum": [
|
||||
"AND",
|
||||
"OR"
|
||||
],
|
||||
"type": "string",
|
||||
"default": "OR"
|
||||
},
|
||||
"df": {
|
||||
"description": "The field to use as default where no field prefix is given in the query string.",
|
||||
"type": "string"
|
||||
},
|
||||
"expand_wildcards": {
|
||||
"description": "Whether to expand wildcard expression to concrete indices that are open, closed or both.",
|
||||
"enum": [
|
||||
"all",
|
||||
"closed",
|
||||
"hidden",
|
||||
"none",
|
||||
"open"
|
||||
],
|
||||
"type": "string",
|
||||
"default": "open"
|
||||
},
|
||||
"from": {
|
||||
"description": "Starting offset.",
|
||||
"type": "number",
|
||||
"default": 0
|
||||
},
|
||||
"ignore_unavailable": {
|
||||
"description": "Whether specified concrete indices should be ignored when unavailable (missing or closed)",
|
||||
"type": "boolean"
|
||||
},
|
||||
"lenient": {
|
||||
"description": "Specify whether format-based query failures (such as providing text to a numeric field) should be ignored.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"max_docs": {
|
||||
"type": "integer",
|
||||
"description": "Maximum number of documents to process. Defaults to all documents."
|
||||
},
|
||||
"preference": {
|
||||
"description": "Specify the node or shard the operation should be performed on.",
|
||||
"type": "string",
|
||||
"default": "random"
|
||||
},
|
||||
"pretty": {
|
||||
"description": "Pretty format the returned JSON response.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"q": {
|
||||
"description": "Query in the Lucene query string syntax.",
|
||||
"type": "string"
|
||||
},
|
||||
"request_cache": {
|
||||
"description": "Specify if request cache should be used for this request or not, defaults to index level setting.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"refresh": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"type": "boolean"
|
||||
}
|
||||
],
|
||||
"description": "If true, Elasticsearch refreshes all shards involved in the delete by query after the request completes. Defaults to false.",
|
||||
"enum": [
|
||||
"true",
|
||||
"false",
|
||||
true,
|
||||
false,
|
||||
"wait_for"
|
||||
],
|
||||
"default": false
|
||||
},
|
||||
"requests_per_second": {
|
||||
"type": "integer",
|
||||
"description": "The throttle for this request in sub-requests per second. Defaults to -1 (no throttle).",
|
||||
"default": -1
|
||||
},
|
||||
"routing": {
|
||||
"type": "string",
|
||||
"description": "Custom value used to route operations to a specific shard."
|
||||
},
|
||||
"scroll": {
|
||||
"type": "string",
|
||||
"description": "Period to retain the search context for scrolling. See Scroll search results."
|
||||
},
|
||||
"scroll_size": {
|
||||
"type": "integer",
|
||||
"description": "Size of the scroll request that powers the operation. Defaults to 1000.",
|
||||
"default": 1000
|
||||
},
|
||||
"search_type": {
|
||||
"description": "Search operation type.",
|
||||
"enum": [
|
||||
"dfs_query_then_fetch",
|
||||
"query_then_fetch"
|
||||
],
|
||||
"type": "string"
|
||||
},
|
||||
"search_timeout": {
|
||||
"type": "string",
|
||||
"description": "Explicit timeout for each search request. Defaults to no timeout."
|
||||
},
|
||||
"slices": {
|
||||
"type": "integer",
|
||||
"description": "The number of slices this task should be divided into. Defaults to 1 meaning the task isn't sliced into subtasks."
|
||||
},
|
||||
"sort": {
|
||||
"description": "A comma-separated list of <field>:<direction> pairs.",
|
||||
"examples": [
|
||||
"name:asc",
|
||||
[
|
||||
"rating:asc",
|
||||
"created_at:desc"
|
||||
]
|
||||
],
|
||||
"anyOf": [
|
||||
{
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"type": "array"
|
||||
},
|
||||
{
|
||||
"type": "string"
|
||||
}
|
||||
]
|
||||
},
|
||||
"_source": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"type": "array"
|
||||
}
|
||||
],
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": "True or false to return the _source field or not, or a list of fields to return."
|
||||
},
|
||||
"_source_excludes": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": "A comma-separated list of source fields to exclude from the response.\n\nYou can also use this parameter to exclude fields from the subset specified in _source_includes query parameter.\n\nIf the _source parameter is false, this parameter is ignored."
|
||||
},
|
||||
"_source_includes": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": "A comma-separated list of source fields to include in the response.\n\nIf this parameter is specified, only these source fields are returned. You can exclude fields from this subset using the _source_excludes query parameter.\n\nIf the _source parameter is false, this parameter is ignored."
|
||||
},
|
||||
"stats": {
|
||||
"description": "Specific tag of the request for logging and statistical purposes",
|
||||
"anyOf": [
|
||||
{
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"type": "array"
|
||||
},
|
||||
{
|
||||
"type": "string"
|
||||
}
|
||||
]
|
||||
},
|
||||
"terminate_after": {
|
||||
"description": "The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early. Elasticsearch collects documents before sorting.\nUse with caution. Elasticsearch applies this parameter to each shard handling the request. When possible, let Elasticsearch perform early termination automatically. Avoid specifying this parameter for requests that target data streams with backing indices across multiple data tiers.",
|
||||
"type": "number"
|
||||
},
|
||||
"timeout": {
|
||||
"type": "string",
|
||||
"description": "Period each deletion request waits for active shards. Defaults to 1m (one minute).",
|
||||
"default": "1m"
|
||||
},
|
||||
"version": {
|
||||
"description": "Explicit version number for concurrency control. The specified version must match the current version of the document for the request to succeed.",
|
||||
"type": "integer"
|
||||
},
|
||||
"wait_for_active_shards": {
|
||||
"type": "string",
|
||||
"description": "The number of shard copies that must be active before proceeding with the operation. Set to all or any positive integer up to the total number of shards in the index (number_of_replicas+1). Default: 1, the primary shard.",
|
||||
"default": "1"
|
||||
}
|
||||
},
|
||||
"errorMessage": {
|
||||
"type": "ElasticsearchDelete request properties should be an object."
|
||||
}
|
||||
}
|
@ -17,11 +17,10 @@
|
||||
import { Client } from '@elastic/elasticsearch';
|
||||
import { validate } from '@lowdefy/ajv';
|
||||
|
||||
import elasticsearchDeleteByQuery from './ElasticsearchDeleteByQuery.js';
|
||||
import requestIndex from './index.js';
|
||||
import schema from './ElasticsearchDeleteByQuery.json';
|
||||
import ElasticsearchDeleteByQuery from './ElasticsearchDeleteByQuery.js';
|
||||
|
||||
const { checkRead, checkWrite } = requestIndex.meta;
|
||||
const { checkRead, checkWrite } = ElasticsearchDeleteByQuery.meta;
|
||||
const schema = ElasticsearchDeleteByQuery.schema;
|
||||
|
||||
const mockElasticsearchClient = jest.fn(() => mockElasticsearchClient);
|
||||
mockElasticsearchClient.deleteByQuery = jest.fn(() => mockElasticsearchClient);
|
||||
@ -81,7 +80,7 @@ test('ElasticsearchDeleteByQuery', async () => {
|
||||
},
|
||||
},
|
||||
};
|
||||
const res = await elasticsearchDeleteByQuery({ request, connection });
|
||||
const res = await ElasticsearchDeleteByQuery({ request, connection });
|
||||
expect(Client.mock.calls).toEqual([
|
||||
[
|
||||
{
|
||||
|
@ -1,26 +0,0 @@
|
||||
/*
|
||||
Copyright 2020-2021 Lowdefy, Inc
|
||||
|
||||
Licensed 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.
|
||||
*/
|
||||
|
||||
export default {
|
||||
import: {
|
||||
path: 'connections/Elasticsearch/ElasticsearchDeleteByQuery/ElasticsearchDeleteByQuery.js',
|
||||
schema: 'connections/Elasticsearch/ElasticsearchDeleteByQuery/ElasticsearchDeleteByQuery.json',
|
||||
},
|
||||
meta: {
|
||||
checkRead: false,
|
||||
checkWrite: true,
|
||||
},
|
||||
};
|
@ -0,0 +1,237 @@
|
||||
/*
|
||||
Copyright 2020-2021 Lowdefy, Inc
|
||||
|
||||
Licensed 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.
|
||||
*/
|
||||
|
||||
export default {
|
||||
$schema: 'http://json-schema.org/draft-07/schema#',
|
||||
title: 'Lowdefy Request Schema - ElasticsearchDeleteByQuery',
|
||||
type: 'object',
|
||||
description: 'Deletes documents that match the specified query.',
|
||||
properties: {
|
||||
index: {
|
||||
type: 'string',
|
||||
description: 'The name of the index.',
|
||||
},
|
||||
allow_no_indices: {
|
||||
type: 'boolean',
|
||||
description:
|
||||
'If false, the request returns an error if any wildcard expression, index alias, or _all value targets only missing or closed indices. This behavior applies even if the request targets other open indices. For example, a request targeting foo*,bar* returns an error if an index starts with foo but no index starts with bar.',
|
||||
default: true,
|
||||
},
|
||||
analyzer: {
|
||||
description: 'The analyzer to use for the query string.',
|
||||
type: 'string',
|
||||
},
|
||||
analyze_wildcard: {
|
||||
description: 'Specify whether wildcard and prefix queries should be analyzed.',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
},
|
||||
conflicts: {
|
||||
type: 'string',
|
||||
enum: ['abort', 'proceed'],
|
||||
description:
|
||||
'What to do if delete by query hits version conflicts: abort or proceed. Defaults to abort.',
|
||||
default: 'abort',
|
||||
},
|
||||
default_operator: {
|
||||
description: 'The default operator for query string query (AND or OR).',
|
||||
enum: ['AND', 'OR'],
|
||||
type: 'string',
|
||||
default: 'OR',
|
||||
},
|
||||
df: {
|
||||
description:
|
||||
'The field to use as default where no field prefix is given in the query string.',
|
||||
type: 'string',
|
||||
},
|
||||
expand_wildcards: {
|
||||
description:
|
||||
'Whether to expand wildcard expression to concrete indices that are open, closed or both.',
|
||||
enum: ['all', 'closed', 'hidden', 'none', 'open'],
|
||||
type: 'string',
|
||||
default: 'open',
|
||||
},
|
||||
from: {
|
||||
description: 'Starting offset.',
|
||||
type: 'number',
|
||||
default: 0,
|
||||
},
|
||||
ignore_unavailable: {
|
||||
description:
|
||||
'Whether specified concrete indices should be ignored when unavailable (missing or closed)',
|
||||
type: 'boolean',
|
||||
},
|
||||
lenient: {
|
||||
description:
|
||||
'Specify whether format-based query failures (such as providing text to a numeric field) should be ignored.',
|
||||
type: 'boolean',
|
||||
},
|
||||
max_docs: {
|
||||
type: 'integer',
|
||||
description: 'Maximum number of documents to process. Defaults to all documents.',
|
||||
},
|
||||
preference: {
|
||||
description: 'Specify the node or shard the operation should be performed on.',
|
||||
type: 'string',
|
||||
default: 'random',
|
||||
},
|
||||
pretty: {
|
||||
description: 'Pretty format the returned JSON response.',
|
||||
type: 'boolean',
|
||||
},
|
||||
q: {
|
||||
description: 'Query in the Lucene query string syntax.',
|
||||
type: 'string',
|
||||
},
|
||||
request_cache: {
|
||||
description:
|
||||
'Specify if request cache should be used for this request or not, defaults to index level setting.',
|
||||
type: 'boolean',
|
||||
},
|
||||
refresh: {
|
||||
anyOf: [
|
||||
{
|
||||
type: 'string',
|
||||
},
|
||||
{
|
||||
type: 'boolean',
|
||||
},
|
||||
],
|
||||
description:
|
||||
'If true, Elasticsearch refreshes all shards involved in the delete by query after the request completes. Defaults to false.',
|
||||
enum: ['true', 'false', true, false, 'wait_for'],
|
||||
default: false,
|
||||
},
|
||||
requests_per_second: {
|
||||
type: 'integer',
|
||||
description:
|
||||
'The throttle for this request in sub-requests per second. Defaults to -1 (no throttle).',
|
||||
default: -1,
|
||||
},
|
||||
routing: {
|
||||
type: 'string',
|
||||
description: 'Custom value used to route operations to a specific shard.',
|
||||
},
|
||||
scroll: {
|
||||
type: 'string',
|
||||
description: 'Period to retain the search context for scrolling. See Scroll search results.',
|
||||
},
|
||||
scroll_size: {
|
||||
type: 'integer',
|
||||
description: 'Size of the scroll request that powers the operation. Defaults to 1000.',
|
||||
default: 1000,
|
||||
},
|
||||
search_type: {
|
||||
description: 'Search operation type.',
|
||||
enum: ['dfs_query_then_fetch', 'query_then_fetch'],
|
||||
type: 'string',
|
||||
},
|
||||
search_timeout: {
|
||||
type: 'string',
|
||||
description: 'Explicit timeout for each search request. Defaults to no timeout.',
|
||||
},
|
||||
slices: {
|
||||
type: 'integer',
|
||||
description:
|
||||
"The number of slices this task should be divided into. Defaults to 1 meaning the task isn't sliced into subtasks.",
|
||||
},
|
||||
sort: {
|
||||
description: 'A comma-separated list of <field>:<direction> pairs.',
|
||||
examples: ['name:asc', ['rating:asc', 'created_at:desc']],
|
||||
anyOf: [
|
||||
{
|
||||
items: {
|
||||
type: 'string',
|
||||
},
|
||||
type: 'array',
|
||||
},
|
||||
{
|
||||
type: 'string',
|
||||
},
|
||||
],
|
||||
},
|
||||
_source: {
|
||||
anyOf: [
|
||||
{
|
||||
type: 'boolean',
|
||||
},
|
||||
{
|
||||
type: 'array',
|
||||
},
|
||||
],
|
||||
items: {
|
||||
type: 'string',
|
||||
},
|
||||
description:
|
||||
'True or false to return the _source field or not, or a list of fields to return.',
|
||||
},
|
||||
_source_excludes: {
|
||||
type: 'array',
|
||||
items: {
|
||||
type: 'string',
|
||||
},
|
||||
description:
|
||||
'A comma-separated list of source fields to exclude from the response.\n\nYou can also use this parameter to exclude fields from the subset specified in _source_includes query parameter.\n\nIf the _source parameter is false, this parameter is ignored.',
|
||||
},
|
||||
_source_includes: {
|
||||
type: 'array',
|
||||
items: {
|
||||
type: 'string',
|
||||
},
|
||||
description:
|
||||
'A comma-separated list of source fields to include in the response.\n\nIf this parameter is specified, only these source fields are returned. You can exclude fields from this subset using the _source_excludes query parameter.\n\nIf the _source parameter is false, this parameter is ignored.',
|
||||
},
|
||||
stats: {
|
||||
description: 'Specific tag of the request for logging and statistical purposes',
|
||||
anyOf: [
|
||||
{
|
||||
items: {
|
||||
type: 'string',
|
||||
},
|
||||
type: 'array',
|
||||
},
|
||||
{
|
||||
type: 'string',
|
||||
},
|
||||
],
|
||||
},
|
||||
terminate_after: {
|
||||
description:
|
||||
'The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early. Elasticsearch collects documents before sorting.\nUse with caution. Elasticsearch applies this parameter to each shard handling the request. When possible, let Elasticsearch perform early termination automatically. Avoid specifying this parameter for requests that target data streams with backing indices across multiple data tiers.',
|
||||
type: 'number',
|
||||
},
|
||||
timeout: {
|
||||
type: 'string',
|
||||
description:
|
||||
'Period each deletion request waits for active shards. Defaults to 1m (one minute).',
|
||||
default: '1m',
|
||||
},
|
||||
version: {
|
||||
description:
|
||||
'Explicit version number for concurrency control. The specified version must match the current version of the document for the request to succeed.',
|
||||
type: 'integer',
|
||||
},
|
||||
wait_for_active_shards: {
|
||||
type: 'string',
|
||||
description:
|
||||
'The number of shard copies that must be active before proceeding with the operation. Set to all or any positive integer up to the total number of shards in the index (number_of_replicas+1). Default: 1, the primary shard.',
|
||||
default: '1',
|
||||
},
|
||||
},
|
||||
errorMessage: {
|
||||
type: 'ElasticsearchDelete request properties should be an object.',
|
||||
},
|
||||
};
|
@ -15,8 +15,9 @@
|
||||
*/
|
||||
|
||||
import { Client } from '@elastic/elasticsearch';
|
||||
import schema from './schema.js';
|
||||
|
||||
async function elasticsearchIndex({ request, connection }) {
|
||||
async function ElasticsearchIndex({ request, connection }) {
|
||||
const client = new Client(connection);
|
||||
const body = {
|
||||
...request,
|
||||
@ -31,4 +32,10 @@ async function elasticsearchIndex({ request, connection }) {
|
||||
};
|
||||
}
|
||||
|
||||
export default elasticsearchIndex;
|
||||
ElasticsearchIndex.schema = schema;
|
||||
ElasticsearchIndex.meta = {
|
||||
checkRead: false,
|
||||
checkWrite: true,
|
||||
};
|
||||
|
||||
export default ElasticsearchIndex;
|
||||
|
@ -1,100 +0,0 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"title": "Lowdefy Request Schema - ElasticsearchIndex",
|
||||
"type": "object",
|
||||
"description": "Adds a JSON document to the specified data stream or index and makes it searchable. If the target is an index and the document already exists, the request updates the document and increments its version.",
|
||||
"required": [
|
||||
"body"
|
||||
],
|
||||
"properties": {
|
||||
"id": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"type": "number"
|
||||
}
|
||||
],
|
||||
"description": "Unique identifier for the document."
|
||||
},
|
||||
"index": {
|
||||
"type": "string",
|
||||
"description": "The name of the index."
|
||||
},
|
||||
"if_seq_no": {
|
||||
"type": "integer",
|
||||
"description": "Only perform the operation if the document has this sequence number. See Optimistic concurrency control."
|
||||
},
|
||||
"if_primary_term": {
|
||||
"type": "integer",
|
||||
"description": "Only perform the operation if the document has this primary term. See Optimistic concurrency control."
|
||||
},
|
||||
"op_type": {
|
||||
"type": "string",
|
||||
"description": "Set to create to only index the document if it does not already exist (put if absent). If a document with the specified _id already exists, the indexing operation will fail. Same as using the <index>/_create endpoint. Valid values: index, create. If document id is specified, it defaults to index. Otherwise, it defaults to create. If the request targets a data stream, an op_type of create is required. See Add documents to a data stream.",
|
||||
"enum": [
|
||||
"index",
|
||||
"create"
|
||||
],
|
||||
"default": "create"
|
||||
},
|
||||
"pipeline": {
|
||||
"type": "string",
|
||||
"description": "ID of the pipeline to use to preprocess incoming documents."
|
||||
},
|
||||
"refresh": {
|
||||
"type": "string",
|
||||
"description": "If true, Elasticsearch refreshes the affected shards to make this operation visible to search, if wait_for then wait for a refresh to make this operation visible to search, if false do nothing with refreshes. Valid values: true, false, wait_for. Default: false.",
|
||||
"enum": [
|
||||
"true",
|
||||
"false",
|
||||
"wait_for"
|
||||
],
|
||||
"default": false
|
||||
},
|
||||
"routing": {
|
||||
"description": "Custom value used to route operations to a specific shard.",
|
||||
"type": "string"
|
||||
},
|
||||
"timeout": {
|
||||
"type": "string",
|
||||
"description": "Period the request waits for the following operations:\n\nAutomatic index creation\nDynamic mapping updates\nWaiting for active shards\nDefaults to 1m (one minute). This guarantees Elasticsearch waits for at least the timeout before failing. The actual wait time could be longer, particularly when multiple waits occur.",
|
||||
"default": "1m"
|
||||
},
|
||||
"version": {
|
||||
"description": "Explicit version number for concurrency control. The specified version must match the current version of the document for the request to succeed.",
|
||||
"type": "integer"
|
||||
},
|
||||
"version_type": {
|
||||
"type": "string",
|
||||
"description": "Specific version type: external, external_gte.",
|
||||
"enum": [
|
||||
"internal",
|
||||
"external",
|
||||
"external_gte"
|
||||
]
|
||||
},
|
||||
"wait_for_active_shard": {
|
||||
"type": "string",
|
||||
"description": "The number of shard copies that must be active before proceeding with the operation. Set to all or any positive integer up to the total number of shards in the index (number_of_replicas+1). Default: 1, the primary shard.",
|
||||
"default": "1"
|
||||
},
|
||||
"require_alias": {
|
||||
"type": "boolean",
|
||||
"description": "If true, the destination must be an index alias. Defaults to false.",
|
||||
"default": false
|
||||
},
|
||||
"body": {
|
||||
"type": "object",
|
||||
"description": "Request body contains the JSON source for the document data.",
|
||||
"additionalProperties": true
|
||||
}
|
||||
},
|
||||
"errorMessage": {
|
||||
"type": "ElasticsearchIndex request properties should be an object.",
|
||||
"required": {
|
||||
"body": "ElasticsearchIndex request should have required property \"body\"."
|
||||
}
|
||||
}
|
||||
}
|
@ -17,11 +17,10 @@
|
||||
import { Client } from '@elastic/elasticsearch';
|
||||
import { validate } from '@lowdefy/ajv';
|
||||
|
||||
import elasticsearchIndex from './ElasticsearchIndex.js';
|
||||
import requestIndex from './index.js';
|
||||
import schema from './ElasticsearchIndex.json';
|
||||
import ElasticsearchIndex from './ElasticsearchIndex.js';
|
||||
|
||||
const { checkRead, checkWrite } = requestIndex.meta;
|
||||
const { checkRead, checkWrite } = ElasticsearchIndex.meta;
|
||||
const schema = ElasticsearchIndex.schema;
|
||||
|
||||
const mockElasticsearchClient = jest.fn(() => mockElasticsearchClient);
|
||||
mockElasticsearchClient.index = jest.fn(() => mockElasticsearchClient);
|
||||
@ -108,7 +107,7 @@ test('ElasticsearchIndex', async () => {
|
||||
foo: 'bar',
|
||||
},
|
||||
};
|
||||
const res = await elasticsearchIndex({ request, connection });
|
||||
const res = await ElasticsearchIndex({ request, connection });
|
||||
expect(Client.mock.calls).toEqual([
|
||||
[
|
||||
{
|
||||
|
@ -0,0 +1,111 @@
|
||||
/*
|
||||
Copyright 2020-2021 Lowdefy, Inc
|
||||
|
||||
Licensed 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.
|
||||
*/
|
||||
|
||||
export default {
|
||||
$schema: 'http://json-schema.org/draft-07/schema#',
|
||||
title: 'Lowdefy Request Schema - ElasticsearchIndex',
|
||||
type: 'object',
|
||||
description:
|
||||
'Adds a JSON document to the specified data stream or index and makes it searchable. If the target is an index and the document already exists, the request updates the document and increments its version.',
|
||||
required: ['body'],
|
||||
properties: {
|
||||
id: {
|
||||
anyOf: [
|
||||
{
|
||||
type: 'string',
|
||||
},
|
||||
{
|
||||
type: 'number',
|
||||
},
|
||||
],
|
||||
description: 'Unique identifier for the document.',
|
||||
},
|
||||
index: {
|
||||
type: 'string',
|
||||
description: 'The name of the index.',
|
||||
},
|
||||
if_seq_no: {
|
||||
type: 'integer',
|
||||
description:
|
||||
'Only perform the operation if the document has this sequence number. See Optimistic concurrency control.',
|
||||
},
|
||||
if_primary_term: {
|
||||
type: 'integer',
|
||||
description:
|
||||
'Only perform the operation if the document has this primary term. See Optimistic concurrency control.',
|
||||
},
|
||||
op_type: {
|
||||
type: 'string',
|
||||
description:
|
||||
'Set to create to only index the document if it does not already exist (put if absent). If a document with the specified _id already exists, the indexing operation will fail. Same as using the <index>/_create endpoint. Valid values: index, create. If document id is specified, it defaults to index. Otherwise, it defaults to create. If the request targets a data stream, an op_type of create is required. See Add documents to a data stream.',
|
||||
enum: ['index', 'create'],
|
||||
default: 'create',
|
||||
},
|
||||
pipeline: {
|
||||
type: 'string',
|
||||
description: 'ID of the pipeline to use to preprocess incoming documents.',
|
||||
},
|
||||
refresh: {
|
||||
type: 'string',
|
||||
description:
|
||||
'If true, Elasticsearch refreshes the affected shards to make this operation visible to search, if wait_for then wait for a refresh to make this operation visible to search, if false do nothing with refreshes. Valid values: true, false, wait_for. Default: false.',
|
||||
enum: ['true', 'false', 'wait_for'],
|
||||
default: false,
|
||||
},
|
||||
routing: {
|
||||
description: 'Custom value used to route operations to a specific shard.',
|
||||
type: 'string',
|
||||
},
|
||||
timeout: {
|
||||
type: 'string',
|
||||
description:
|
||||
'Period the request waits for the following operations:\n\nAutomatic index creation\nDynamic mapping updates\nWaiting for active shards\nDefaults to 1m (one minute). This guarantees Elasticsearch waits for at least the timeout before failing. The actual wait time could be longer, particularly when multiple waits occur.',
|
||||
default: '1m',
|
||||
},
|
||||
version: {
|
||||
description:
|
||||
'Explicit version number for concurrency control. The specified version must match the current version of the document for the request to succeed.',
|
||||
type: 'integer',
|
||||
},
|
||||
version_type: {
|
||||
type: 'string',
|
||||
description: 'Specific version type: external, external_gte.',
|
||||
enum: ['internal', 'external', 'external_gte'],
|
||||
},
|
||||
wait_for_active_shard: {
|
||||
type: 'string',
|
||||
description:
|
||||
'The number of shard copies that must be active before proceeding with the operation. Set to all or any positive integer up to the total number of shards in the index (number_of_replicas+1). Default: 1, the primary shard.',
|
||||
default: '1',
|
||||
},
|
||||
require_alias: {
|
||||
type: 'boolean',
|
||||
description: 'If true, the destination must be an index alias. Defaults to false.',
|
||||
default: false,
|
||||
},
|
||||
body: {
|
||||
type: 'object',
|
||||
description: 'Request body contains the JSON source for the document data.',
|
||||
additionalProperties: true,
|
||||
},
|
||||
},
|
||||
errorMessage: {
|
||||
type: 'ElasticsearchIndex request properties should be an object.',
|
||||
required: {
|
||||
body: 'ElasticsearchIndex request should have required property "body".',
|
||||
},
|
||||
},
|
||||
};
|
@ -1,457 +0,0 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"title": "Lowdefy Connection Schema - Elasticsearch",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"node": {
|
||||
"description": "The Elasticsearch endpoint to use. It can be a single string, an array of strings, or an object (or an array of objects) that represents the node",
|
||||
"examples": [
|
||||
"http://localhost:9200",
|
||||
"https://your.node.company.tld:443"
|
||||
],
|
||||
"anyOf": [
|
||||
{
|
||||
"items": {
|
||||
"type": "string",
|
||||
"format": "uri",
|
||||
"pattern": "^(https?)://"
|
||||
},
|
||||
"type": "array"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/NodeOptions"
|
||||
},
|
||||
{
|
||||
"items": {
|
||||
"$ref": "#/definitions/NodeOptions"
|
||||
},
|
||||
"type": "array"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"format": "uri",
|
||||
"pattern": "^(https?)://"
|
||||
}
|
||||
]
|
||||
},
|
||||
"nodes": {
|
||||
"description": "The Elasticsearch endpoint to use. It can be a single string, an array of strings, or an object (or an array of objects) that represents the node",
|
||||
"examples": [
|
||||
{
|
||||
"url": "http://localhost:9200",
|
||||
"ssl": "ssl options",
|
||||
"agent": "http agent options",
|
||||
"id": "custom node id",
|
||||
"headers": {
|
||||
"X-Foo": "Bar"
|
||||
},
|
||||
"roles": {
|
||||
"master": true,
|
||||
"data": true,
|
||||
"ingest": true,
|
||||
"ml": false
|
||||
}
|
||||
},
|
||||
"http://localhost:9200",
|
||||
"https://your.node.company.tld:443"
|
||||
],
|
||||
"anyOf": [
|
||||
{
|
||||
"items": {
|
||||
"type": "string",
|
||||
"format": "uri",
|
||||
"pattern": "^(https?)://"
|
||||
},
|
||||
"type": "array"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/NodeOptions"
|
||||
},
|
||||
{
|
||||
"items": {
|
||||
"$ref": "#/definitions/NodeOptions"
|
||||
},
|
||||
"type": "array"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"format": "uri",
|
||||
"pattern": "^(https?)://"
|
||||
}
|
||||
]
|
||||
},
|
||||
"index": {
|
||||
"description": "Default index to use for requests.",
|
||||
"type": "string"
|
||||
},
|
||||
"auth": {
|
||||
"description": "Your authentication data. You can use both basic authentication and ApiKey.",
|
||||
"examples": [
|
||||
{
|
||||
"username": "elastic",
|
||||
"password": "changeMe"
|
||||
},
|
||||
{
|
||||
"apiKey": "base64EncodedApiKey"
|
||||
}
|
||||
],
|
||||
"anyOf": [
|
||||
{
|
||||
"$ref": "#/definitions/ApiKeyAuth"
|
||||
},
|
||||
{
|
||||
"$ref": "#/definitions/BasicAuth"
|
||||
}
|
||||
],
|
||||
"errorMessage": {
|
||||
"anyOf": "Elasticsearch connection property \"auth\" should be an object containing credentials"
|
||||
}
|
||||
},
|
||||
"maxRetries": {
|
||||
"description": "Max number of retries for each request.",
|
||||
"type": "number",
|
||||
"default": 3,
|
||||
"minimum": 0
|
||||
},
|
||||
"requestTimeout": {
|
||||
"description": "Max request timeout in milliseconds for each request.",
|
||||
"type": "number",
|
||||
"default": 30000,
|
||||
"exclusiveMinimum": 0
|
||||
},
|
||||
"pingTimeout": {
|
||||
"description": "Max ping request timeout in milliseconds for each request.",
|
||||
"type": "number",
|
||||
"default": 3000,
|
||||
"exclusiveMinimum": 0
|
||||
},
|
||||
"sniffInterval": {
|
||||
"description": "Perform a sniff operation every n milliseconds. Sniffing might not be the best solution for you, take a look here to know more: https://www.elastic.co/blog/elasticsearch-sniffing-best-practices-what-when-why-how",
|
||||
"type": [
|
||||
"number",
|
||||
"boolean"
|
||||
],
|
||||
"default": false
|
||||
},
|
||||
"sniffOnStart": {
|
||||
"description": "Perform a sniff once the client is started. Sniffing might not be the best solution for you, take a look here to know more: https://www.elastic.co/blog/elasticsearch-sniffing-best-practices-what-when-why-how",
|
||||
"type": "boolean"
|
||||
},
|
||||
"sniffEndpoint": {
|
||||
"description": "Endpoint to ping during a sniff.",
|
||||
"type": "string",
|
||||
"default": "_nodes/_all/http"
|
||||
},
|
||||
"sniffOnConnectionFault": {
|
||||
"description": "Perform a sniff on connection fault. Sniffing might not be the best solution for you, take a look here to know more: https://www.elastic.co/blog/elasticsearch-sniffing-best-practices-what-when-why-how",
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"resurrectStrategy": {
|
||||
"description": "Configure the node resurrection strategy.",
|
||||
"enum": [
|
||||
"none",
|
||||
"optimistic",
|
||||
"ping"
|
||||
],
|
||||
"type": "string",
|
||||
"default": "ping"
|
||||
},
|
||||
"suggestCompression": {
|
||||
"description": "Adds accept-encoding header to every request.",
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"compression": {
|
||||
"description": "Enables gzip request body compression.",
|
||||
"enum": [
|
||||
"gzip"
|
||||
],
|
||||
"type": [
|
||||
"string",
|
||||
"boolean"
|
||||
],
|
||||
"default": false
|
||||
},
|
||||
"ssl": {
|
||||
"$ref": "#/definitions/ConnectionOptions"
|
||||
},
|
||||
"proxy": {
|
||||
"description": "If you are using an http(s) proxy, you can put its url here. The client will automatically handle the connection to it.",
|
||||
"type": "string",
|
||||
"format": "uri",
|
||||
"pattern": "^(https?)://",
|
||||
"examples": [
|
||||
"http://localhost:8080",
|
||||
"http://user:pwd@localhost:8080"
|
||||
],
|
||||
"default": null
|
||||
},
|
||||
"agent": {
|
||||
"description": "HTTP agent options. If you want to disable the HTTP agent use entirely (and disable the `keep-alive` feature), set the agent to `false`. See https://nodejs.org/api/http.html#http_new_agent_options.",
|
||||
"default": null,
|
||||
"examples": [
|
||||
{
|
||||
"agent": "options"
|
||||
},
|
||||
{
|
||||
"agent": false
|
||||
}
|
||||
],
|
||||
"anyOf": [
|
||||
{
|
||||
"$ref": "#/definitions/AgentOptions"
|
||||
},
|
||||
{
|
||||
"enum": [
|
||||
false
|
||||
],
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"type": "object"
|
||||
}
|
||||
]
|
||||
},
|
||||
"name": {
|
||||
"description": "The name to identify the client instance in the events.",
|
||||
"type": "string",
|
||||
"default": "elasticsearch-js"
|
||||
},
|
||||
"opaqueIdPrefix": {
|
||||
"description": "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,
|
||||
"type": "string"
|
||||
},
|
||||
"headers": {
|
||||
"description": "A set of custom headers to send in every request.",
|
||||
"examples": [
|
||||
{
|
||||
"X-Foo": "Bar"
|
||||
}
|
||||
],
|
||||
"type": "object",
|
||||
"default": { }
|
||||
},
|
||||
"context": {
|
||||
"description": "A custom object that you can use for observability in your events. It will be merged with the API level context option.",
|
||||
"type": "object",
|
||||
"default": null
|
||||
},
|
||||
"enableMetaHeader": {
|
||||
"description": "If true, adds an header named 'x-elastic-client-meta', containing some minimal telemetry data, such as the client and platform version.",
|
||||
"type": "boolean",
|
||||
"default": true
|
||||
},
|
||||
"cloud": {
|
||||
"description": "Custom configuration for connecting to Elastic Cloud. See Authentication for more details: https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/auth-reference.html",
|
||||
"examples": [
|
||||
{
|
||||
"id": "name:bG9jYWxob3N0JGFiY2QkZWZnaA=="
|
||||
}
|
||||
],
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"password": {
|
||||
"type": "string"
|
||||
},
|
||||
"username": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"type": "object",
|
||||
"default": null
|
||||
},
|
||||
"disablePrototypePoisoningProtection": {
|
||||
"description": "By the default the client will protect you against prototype poisoning attacks. If needed you can disable prototype poisoning protection entirely or one of the two checks. Read the `secure-json-parse` documentation to learn more: https://github.com/fastify/secure-json-parse",
|
||||
"enum": [
|
||||
"constructor",
|
||||
false,
|
||||
"proto",
|
||||
true
|
||||
],
|
||||
"default": false
|
||||
},
|
||||
"read": {
|
||||
"type": "boolean",
|
||||
"default": true,
|
||||
"description": "Allow reads from the Elasticsearch index.",
|
||||
"errorMessage": {
|
||||
"type": "Elasticsearch connection property \"read\" should be a boolean."
|
||||
}
|
||||
},
|
||||
"write": {
|
||||
"type": "boolean",
|
||||
"default": false,
|
||||
"description": "Allow writes to the Elasticsearch index.",
|
||||
"errorMessage": {
|
||||
"type": "Elasticsearch connection property \"write\" should be a boolean."
|
||||
}
|
||||
}
|
||||
},
|
||||
"definitions": {
|
||||
"AgentOptions": {
|
||||
"description": "Set of configurable options to set on the agent.",
|
||||
"properties": {
|
||||
"keepAlive": {
|
||||
"description": "Keep sockets around even when there are no outstanding requests, so they can be used for future requests without having to reestablish a TCP connection. Not to be confused with the `keep-alive` value of the `Connection` header. The `Connection: keep-alive` header is always sent when using an agent except when the `Connection` header is explicitly specified or when the `keepAlive` and `maxSockets` options are respectively set to `false` and `Infinity`, in which case `Connection: close` will be used.",
|
||||
"default": false,
|
||||
"type": "boolean"
|
||||
},
|
||||
"keepAliveMsecs": {
|
||||
"description": "When using the `keepAlive` option, specifies the initial delay for TCP Keep-Alive packets. Ignored when the `keepAlive` option is `false` or `undefined`",
|
||||
"type": "number",
|
||||
"default": 1000
|
||||
},
|
||||
"maxFreeSockets": {
|
||||
"description": "Maximum number of sockets to leave open in a free state. Only relevant if `keepAlive` is set to `true`",
|
||||
"type": "number",
|
||||
"default": 256
|
||||
},
|
||||
"maxSockets": {
|
||||
"description": "Maximum number of sockets to allow per host. If the same host opens multiple concurrent connections, each request will use new socket until the `maxSockets` value is reached. If the host attempts to open more connections than `maxSockets`, the additional requests will enter into a pending request queue, and will enter active connection state when an existing connection terminates. This makes sure there are at most maxSockets active connections at any point in time, from a given host.",
|
||||
"type": "number",
|
||||
"default": "Infinity"
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
},
|
||||
"ApiKeyAuth": {
|
||||
"description": "The apiKey parameter can be either a base64 encoded string or an object with the values that you can obtain from the create api key endpoint. If you provide both basic authentication credentials and the ApiKey configuration, the ApiKey takes precedence.",
|
||||
"properties": {
|
||||
"apiKey": {
|
||||
"anyOf": [
|
||||
{
|
||||
"properties": {
|
||||
"api_key": {
|
||||
"type": "string"
|
||||
},
|
||||
"id": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
},
|
||||
{
|
||||
"type": "string"
|
||||
}
|
||||
],
|
||||
"errorMessage": {
|
||||
"anyOf": "Elasticsearch API key should be specified as a string, or an object containing Elasticsearch cloud credentials"
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"apiKey"
|
||||
],
|
||||
"type": "object"
|
||||
},
|
||||
"BasicAuth": {
|
||||
"properties": {
|
||||
"password": {
|
||||
"type": "string"
|
||||
},
|
||||
"username": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"username"
|
||||
],
|
||||
"type": "object",
|
||||
"errorMessage": {
|
||||
"required": "Elasticsearch basic auth credentials must consist of at least a username"
|
||||
}
|
||||
},
|
||||
"ConnectionOptions": {
|
||||
"description": "http.SecureContextOptions - See node.js SSL configuration: https://nodejs.org/api/tls.html",
|
||||
"type": "object",
|
||||
"default": null
|
||||
},
|
||||
"NodeOptions": {
|
||||
"examples": [
|
||||
{
|
||||
"url": "http://localhost:9200",
|
||||
"ssl": "ssl options",
|
||||
"agent": "http agent options",
|
||||
"id": "custom node id",
|
||||
"headers": {
|
||||
"X-Foo": "Bar"
|
||||
},
|
||||
"roles": {
|
||||
"master": true,
|
||||
"data": true,
|
||||
"ingest": true,
|
||||
"ml": false
|
||||
}
|
||||
}
|
||||
],
|
||||
"properties": {
|
||||
"agent": {
|
||||
"$ref": "#/definitions/AgentOptions"
|
||||
},
|
||||
"headers": {
|
||||
"type": "object",
|
||||
"examples": [
|
||||
{
|
||||
"X-Foo": "Bar"
|
||||
}
|
||||
]
|
||||
},
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"roles": {
|
||||
"properties": {
|
||||
"data": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"ingest": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"master": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"ml": {
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
},
|
||||
"ssl": {
|
||||
"$ref": "#/definitions/ConnectionOptions"
|
||||
},
|
||||
"url": {
|
||||
"type": "string",
|
||||
"format": "uri",
|
||||
"pattern": "^(https?)://"
|
||||
}
|
||||
},
|
||||
"type": "object"
|
||||
}
|
||||
},
|
||||
"oneOf": [
|
||||
{
|
||||
"required": [
|
||||
"node"
|
||||
]
|
||||
},
|
||||
{
|
||||
"required": [
|
||||
"nodes"
|
||||
]
|
||||
}
|
||||
],
|
||||
"errorMessage": {
|
||||
"type": "Elasticsearch connection properties should be an object.",
|
||||
"oneOf": "Elasticsearch connection should have required property \"node\" or \"nodes\".",
|
||||
"properties": {
|
||||
"maxRetries": "Elasticsearch connection \"maxRetries\" should be 0 or greater",
|
||||
"requestTimeout": "Elasticsearch connection \"requestTimeout\" should be 1 or greater",
|
||||
"pingTimeout": "Elasticsearch connection \"pingTimeout\" should be 1 or greater",
|
||||
"index": "Elasticsearch connection property \"index\" should be a string"
|
||||
}
|
||||
}
|
||||
}
|
@ -16,9 +16,9 @@
|
||||
|
||||
import { Client } from '@elastic/elasticsearch';
|
||||
import { get } from '@lowdefy/helpers';
|
||||
import schema from './ElasticsearchSearch.json';
|
||||
import schema from './schema.js';
|
||||
|
||||
async function elasticsearchSearch({ request, connection }) {
|
||||
async function ElasticsearchSearch({ request, connection }) {
|
||||
const client = new Client(connection);
|
||||
|
||||
const { body: response } = await client.search({
|
||||
@ -49,4 +49,10 @@ async function elasticsearchSearch({ request, connection }) {
|
||||
};
|
||||
}
|
||||
|
||||
export default elasticsearchSearch;
|
||||
ElasticsearchSearch.schema = schema;
|
||||
ElasticsearchSearch.meta = {
|
||||
checkRead: true,
|
||||
checkWrite: false,
|
||||
};
|
||||
|
||||
export default ElasticsearchSearch;
|
||||
|
@ -1,380 +0,0 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"title": "Lowdefy Request Schema - ElasticsearchSearch",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"body": {
|
||||
"type": "object",
|
||||
"description": "The search definition using the Query DSL.",
|
||||
"properties": {
|
||||
"query": {
|
||||
"$ref": "#/definitions/Query"
|
||||
},
|
||||
"aggs": {
|
||||
"description": "The aggregations to request for the search.",
|
||||
"type": "object"
|
||||
}
|
||||
}
|
||||
},
|
||||
"_source": {
|
||||
"description": "True or false to return the _source field or not, or a list of fields to return.",
|
||||
"examples": [["id", "name"], "name", true, false],
|
||||
"anyOf": [
|
||||
{
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"type": "array"
|
||||
},
|
||||
{
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"type": "boolean"
|
||||
}
|
||||
]
|
||||
},
|
||||
"_source_exclude": {
|
||||
"description": "A list of fields to exclude from the returned _source field.",
|
||||
"examples": [["id", "name"], "name"],
|
||||
"anyOf": [
|
||||
{
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"type": "array"
|
||||
},
|
||||
{
|
||||
"type": "string"
|
||||
}
|
||||
]
|
||||
},
|
||||
"_source_excludes": {
|
||||
"description": "A list of fields to exclude from the returned _source field.",
|
||||
"examples": [["id", "name"], "name"],
|
||||
"anyOf": [
|
||||
{
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"type": "array"
|
||||
},
|
||||
{
|
||||
"type": "string"
|
||||
}
|
||||
]
|
||||
},
|
||||
"_source_include": {
|
||||
"description": "A list of fields to extract and return from the _source field.",
|
||||
"examples": [["id", "name"], "name"],
|
||||
"anyOf": [
|
||||
{
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"type": "array"
|
||||
},
|
||||
{
|
||||
"type": "string"
|
||||
}
|
||||
]
|
||||
},
|
||||
"_source_includes": {
|
||||
"description": "A list of fields to extract and return from the _source field.",
|
||||
"examples": [["id", "name"], "name"],
|
||||
"anyOf": [
|
||||
{
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"type": "array"
|
||||
},
|
||||
{
|
||||
"type": "string"
|
||||
}
|
||||
]
|
||||
},
|
||||
"allow_no_indices": {
|
||||
"description": "Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes _all string or when no indices have been specified).",
|
||||
"type": "boolean"
|
||||
},
|
||||
"allow_partial_search_results": {
|
||||
"description": "Indicate if an error should be returned if there is a partial search failure or timeout.",
|
||||
"type": "boolean",
|
||||
"default": true
|
||||
},
|
||||
"analyze_wildcard": {
|
||||
"description": "Specify whether wildcard and prefix queries should be analyzed.",
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"analyzer": {
|
||||
"description": "The analyzer to use for the query string.",
|
||||
"type": "string"
|
||||
},
|
||||
"batched_reduce_size": {
|
||||
"description": "The number of shard results that should be reduced at once on the coordinating node. This value should be used as a protection mechanism to reduce the memory overhead per search request if the potential number of shards in the request can be large.",
|
||||
"type": "number",
|
||||
"default": 512
|
||||
},
|
||||
"ccs_minimize_roundtrips": {
|
||||
"description": "Indicates whether network round-trips should be minimized as part of cross-cluster search requests execution.",
|
||||
"type": "boolean",
|
||||
"default": true
|
||||
},
|
||||
"default_operator": {
|
||||
"description": "The default operator for query string query (AND or OR).",
|
||||
"enum": ["AND", "OR"],
|
||||
"type": "string",
|
||||
"default": "OR"
|
||||
},
|
||||
"df": {
|
||||
"description": "The field to use as default where no field prefix is given in the query string.",
|
||||
"type": "string"
|
||||
},
|
||||
"docvalue_fields": {
|
||||
"description": "A comma-separated list of fields to return as the docvalue representation of a field for each hit.",
|
||||
"anyOf": [
|
||||
{
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"type": "array"
|
||||
},
|
||||
{
|
||||
"type": "string"
|
||||
}
|
||||
]
|
||||
},
|
||||
"error_trace": {
|
||||
"description": "Include the stack trace of returned errors.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"expand_wildcards": {
|
||||
"description": "Whether to expand wildcard expression to concrete indices that are open, closed or both.",
|
||||
"enum": ["all", "closed", "hidden", "none", "open"],
|
||||
"type": "string",
|
||||
"default": "open"
|
||||
},
|
||||
"explain": {
|
||||
"description": "Specify whether to return detailed information about score computation as part of a hit.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"from": {
|
||||
"description": "Starting offset.",
|
||||
"type": "number",
|
||||
"default": 0
|
||||
},
|
||||
"human": {
|
||||
"description": "Return human readable values for statistics.",
|
||||
"type": "boolean",
|
||||
"default": true
|
||||
},
|
||||
"ignore_throttled": {
|
||||
"description": "Whether specified concrete, expanded or aliased indices should be ignored when throttled.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"ignore_unavailable": {
|
||||
"description": "Whether specified concrete indices should be ignored when unavailable (missing or closed)",
|
||||
"type": "boolean"
|
||||
},
|
||||
"index": {
|
||||
"description": "A comma-separated list of index names to search; use _all or empty string to perform the operation on all indices.",
|
||||
"anyOf": [
|
||||
{
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"type": "array"
|
||||
},
|
||||
{
|
||||
"type": "string"
|
||||
}
|
||||
],
|
||||
"examples": ["", "_all", "my_index"]
|
||||
},
|
||||
"lenient": {
|
||||
"description": "Specify whether format-based query failures (such as providing text to a numeric field) should be ignored.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"max_concurrent_shard_requests": {
|
||||
"description": "The number of concurrent shard requests per node this search executes concurrently. This value should be used to limit the impact of the search on the cluster in order to limit the number of concurrent shard requests.",
|
||||
"type": "number",
|
||||
"default": 5
|
||||
},
|
||||
"min_compatible_shard_node": {
|
||||
"description": "The minimum compatible version that all shards involved in search should have for this request to be successful.",
|
||||
"type": "string"
|
||||
},
|
||||
"pre_filter_shard_size": {
|
||||
"description": "A threshold that enforces a pre-filter roundtrip to prefilter search shards based on query rewriting if the number of shards the search request expands to exceeds the threshold. This filter roundtrip can limit the number of shards significantly if for instance a shard can not match any documents based on its rewrite method ie. if date filters are mandatory to match but the shard bounds and the query are disjoint.",
|
||||
"type": "number"
|
||||
},
|
||||
"preference": {
|
||||
"description": "Specify the node or shard the operation should be performed on.",
|
||||
"type": "string",
|
||||
"default": "random"
|
||||
},
|
||||
"pretty": {
|
||||
"description": "Pretty format the returned JSON response.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"q": {
|
||||
"description": "Query in the Lucene query string syntax.",
|
||||
"type": "string"
|
||||
},
|
||||
"request_cache": {
|
||||
"description": "Specify if request cache should be used for this request or not, defaults to index level setting.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"rest_total_hits_as_int": {
|
||||
"description": "Indicates whether hits.total should be rendered as an integer or an object in the rest search response.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"routing": {
|
||||
"description": "A comma-separated list of specific routing values.",
|
||||
"anyOf": [
|
||||
{
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"type": "array"
|
||||
},
|
||||
{
|
||||
"type": "string"
|
||||
}
|
||||
]
|
||||
},
|
||||
"scroll": {
|
||||
"description": "Specify how long a consistent view of the index should be maintained for scrolled search.",
|
||||
"type": "string"
|
||||
},
|
||||
"search_type": {
|
||||
"description": "Search operation type.",
|
||||
"enum": ["dfs_query_then_fetch", "query_then_fetch"],
|
||||
"type": "string"
|
||||
},
|
||||
"seq_no_primary_term": {
|
||||
"description": "Specify whether to return sequence number and primary term of the last modification of each hit",
|
||||
"type": "boolean"
|
||||
},
|
||||
"size": {
|
||||
"description": "Number of hits to return.",
|
||||
"type": "number",
|
||||
"default": 10
|
||||
},
|
||||
"sort": {
|
||||
"description": "A comma-separated list of <field>:<direction> pairs.",
|
||||
"examples": ["name:asc", ["rating:asc", "created_at:desc"]],
|
||||
"anyOf": [
|
||||
{
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"type": "array"
|
||||
},
|
||||
{
|
||||
"type": "string"
|
||||
}
|
||||
]
|
||||
},
|
||||
"source": {
|
||||
"description": "The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.",
|
||||
"type": "string"
|
||||
},
|
||||
"stats": {
|
||||
"description": "Specific tag of the request for logging and statistical purposes",
|
||||
"anyOf": [
|
||||
{
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"type": "array"
|
||||
},
|
||||
{
|
||||
"type": "string"
|
||||
}
|
||||
]
|
||||
},
|
||||
"stored_fields": {
|
||||
"description": "A comma-separated list of stored fields to return as part of a hit",
|
||||
"anyOf": [
|
||||
{
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"type": "array"
|
||||
},
|
||||
{
|
||||
"type": "string"
|
||||
}
|
||||
]
|
||||
},
|
||||
"suggest_field": {
|
||||
"description": "Specify which field to use for suggestions",
|
||||
"type": "string"
|
||||
},
|
||||
"suggest_mode": {
|
||||
"description": "Specify suggest mode",
|
||||
"enum": ["always", "missing", "popular"],
|
||||
"type": "string",
|
||||
"default": "missing"
|
||||
},
|
||||
"suggest_size": {
|
||||
"description": "How many suggestions to return in response",
|
||||
"type": "number"
|
||||
},
|
||||
"suggest_text": {
|
||||
"description": "The source text for which the suggestions should be returned.",
|
||||
"type": "string"
|
||||
},
|
||||
"terminate_after": {
|
||||
"description": "The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early.",
|
||||
"type": "number"
|
||||
},
|
||||
"timeout": {
|
||||
"description": "Explicit operation timeout.",
|
||||
"type": "string"
|
||||
},
|
||||
"track_scores": {
|
||||
"description": "Whether to calculate and return scores even if they are not used for sorting.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"track_total_hits": {
|
||||
"description": "Indicate if the number of documents that match the query should be tracked.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"type": {
|
||||
"description": "A comma-separated list of document types to search; leave empty to perform the operation on all types.",
|
||||
"anyOf": [
|
||||
{
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"type": "array"
|
||||
},
|
||||
{
|
||||
"type": "string"
|
||||
}
|
||||
]
|
||||
},
|
||||
"typed_keys": {
|
||||
"description": "Specify whether aggregation and suggester names should be prefixed by their respective types in the response.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"version": {
|
||||
"description": "Specify whether to return document version as part of a hit",
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
"definitions": {
|
||||
"Query": {
|
||||
"description": "A query expressed in the Elasticsearch query DSL. See https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl.html.",
|
||||
"type": "object",
|
||||
"additionalProperties": true
|
||||
}
|
||||
},
|
||||
"errorMessage": {
|
||||
"type": "ElasticsearchSearch request properties should be an object."
|
||||
}
|
||||
}
|
@ -17,11 +17,10 @@
|
||||
import { Client } from '@elastic/elasticsearch';
|
||||
import { validate } from '@lowdefy/ajv';
|
||||
|
||||
import elasticsearchSearch from './ElasticsearchSearch.js';
|
||||
import requestIndex from './index.js';
|
||||
import schema from './ElasticsearchSearch.json';
|
||||
import ElasticsearchSearch from './ElasticsearchSearch.js';
|
||||
|
||||
const { checkRead, checkWrite } = requestIndex.meta;
|
||||
const { checkRead, checkWrite } = ElasticsearchSearch.meta;
|
||||
const schema = ElasticsearchSearch.schema;
|
||||
|
||||
const mockElasticsearchClient = jest.fn(() => mockElasticsearchClient);
|
||||
mockElasticsearchClient.search = jest.fn(() => mockElasticsearchClient);
|
||||
@ -152,7 +151,7 @@ test('ElasticsearchSearch with match_all query', async () => {
|
||||
},
|
||||
},
|
||||
};
|
||||
const res = await elasticsearchSearch({ request, connection });
|
||||
const res = await ElasticsearchSearch({ request, connection });
|
||||
expect(Client.mock.calls).toEqual([
|
||||
[
|
||||
{
|
||||
@ -354,7 +353,7 @@ test('ElasticsearchSearch exposes total results', async () => {
|
||||
},
|
||||
},
|
||||
};
|
||||
const res = await elasticsearchSearch({ request, connection });
|
||||
const res = await ElasticsearchSearch({ request, connection });
|
||||
expect(res.total).toEqual({ relation: 'eq', value: 1234 });
|
||||
});
|
||||
|
||||
@ -438,7 +437,7 @@ test('ElasticsearchSearch exposes total results over 10k as Infinity', async ()
|
||||
},
|
||||
},
|
||||
};
|
||||
const res = await elasticsearchSearch({ request, connection });
|
||||
const res = await ElasticsearchSearch({ request, connection });
|
||||
expect(res.total).toEqual({ relation: 'gte', value: 10000 });
|
||||
});
|
||||
|
||||
@ -522,7 +521,7 @@ test('ElasticsearchSearch exposes maximum score', async () => {
|
||||
},
|
||||
},
|
||||
};
|
||||
const res = await elasticsearchSearch({ request, connection });
|
||||
const res = await ElasticsearchSearch({ request, connection });
|
||||
expect(res.maxScore).toEqual(42);
|
||||
});
|
||||
|
||||
@ -606,7 +605,7 @@ test('ElasticsearchSearch exposes aggregations', async () => {
|
||||
},
|
||||
},
|
||||
};
|
||||
const res = await elasticsearchSearch({ request, connection });
|
||||
const res = await ElasticsearchSearch({ request, connection });
|
||||
expect(res.aggregations).toEqual({
|
||||
nameAggregation: {
|
||||
doc_count_error_upper_bound: 0,
|
||||
@ -696,7 +695,7 @@ test('ElasticsearchSearch exposes original response body', async () => {
|
||||
},
|
||||
},
|
||||
};
|
||||
const res = await elasticsearchSearch({ request, connection });
|
||||
const res = await ElasticsearchSearch({ request, connection });
|
||||
expect(res.response).toMatchObject(responseData.body);
|
||||
});
|
||||
|
||||
|
@ -1,26 +0,0 @@
|
||||
/*
|
||||
Copyright 2020-2021 Lowdefy, Inc
|
||||
|
||||
Licensed 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.
|
||||
*/
|
||||
|
||||
export default {
|
||||
import: {
|
||||
path: 'connections/Elasticsearch/ElasticsearchSearch/ElasticsearchSearch.js',
|
||||
schema: 'connections/Elasticsearch/ElasticsearchSearch/ElasticsearchSearch.json',
|
||||
},
|
||||
meta: {
|
||||
checkRead: true,
|
||||
checkWrite: false,
|
||||
},
|
||||
};
|
@ -0,0 +1,421 @@
|
||||
/*
|
||||
Copyright 2020-2021 Lowdefy, Inc
|
||||
|
||||
Licensed 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.
|
||||
*/
|
||||
|
||||
export default {
|
||||
$schema: 'http://json-schema.org/draft-07/schema#',
|
||||
title: 'Lowdefy Request Schema - ElasticsearchSearch',
|
||||
type: 'object',
|
||||
properties: {
|
||||
body: {
|
||||
type: 'object',
|
||||
description: 'The search definition using the Query DSL.',
|
||||
properties: {
|
||||
query: {
|
||||
$ref: '#/definitions/Query',
|
||||
},
|
||||
aggs: {
|
||||
description: 'The aggregations to request for the search.',
|
||||
type: 'object',
|
||||
},
|
||||
},
|
||||
},
|
||||
_source: {
|
||||
description:
|
||||
'True or false to return the _source field or not, or a list of fields to return.',
|
||||
examples: [['id', 'name'], 'name', true, false],
|
||||
anyOf: [
|
||||
{
|
||||
items: {
|
||||
type: 'string',
|
||||
},
|
||||
type: 'array',
|
||||
},
|
||||
{
|
||||
type: 'string',
|
||||
},
|
||||
{
|
||||
type: 'boolean',
|
||||
},
|
||||
],
|
||||
},
|
||||
_source_exclude: {
|
||||
description: 'A list of fields to exclude from the returned _source field.',
|
||||
examples: [['id', 'name'], 'name'],
|
||||
anyOf: [
|
||||
{
|
||||
items: {
|
||||
type: 'string',
|
||||
},
|
||||
type: 'array',
|
||||
},
|
||||
{
|
||||
type: 'string',
|
||||
},
|
||||
],
|
||||
},
|
||||
_source_excludes: {
|
||||
description: 'A list of fields to exclude from the returned _source field.',
|
||||
examples: [['id', 'name'], 'name'],
|
||||
anyOf: [
|
||||
{
|
||||
items: {
|
||||
type: 'string',
|
||||
},
|
||||
type: 'array',
|
||||
},
|
||||
{
|
||||
type: 'string',
|
||||
},
|
||||
],
|
||||
},
|
||||
_source_include: {
|
||||
description: 'A list of fields to extract and return from the _source field.',
|
||||
examples: [['id', 'name'], 'name'],
|
||||
anyOf: [
|
||||
{
|
||||
items: {
|
||||
type: 'string',
|
||||
},
|
||||
type: 'array',
|
||||
},
|
||||
{
|
||||
type: 'string',
|
||||
},
|
||||
],
|
||||
},
|
||||
_source_includes: {
|
||||
description: 'A list of fields to extract and return from the _source field.',
|
||||
examples: [['id', 'name'], 'name'],
|
||||
anyOf: [
|
||||
{
|
||||
items: {
|
||||
type: 'string',
|
||||
},
|
||||
type: 'array',
|
||||
},
|
||||
{
|
||||
type: 'string',
|
||||
},
|
||||
],
|
||||
},
|
||||
allow_no_indices: {
|
||||
description:
|
||||
'Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes _all string or when no indices have been specified).',
|
||||
type: 'boolean',
|
||||
},
|
||||
allow_partial_search_results: {
|
||||
description:
|
||||
'Indicate if an error should be returned if there is a partial search failure or timeout.',
|
||||
type: 'boolean',
|
||||
default: true,
|
||||
},
|
||||
analyze_wildcard: {
|
||||
description: 'Specify whether wildcard and prefix queries should be analyzed.',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
},
|
||||
analyzer: {
|
||||
description: 'The analyzer to use for the query string.',
|
||||
type: 'string',
|
||||
},
|
||||
batched_reduce_size: {
|
||||
description:
|
||||
'The number of shard results that should be reduced at once on the coordinating node. This value should be used as a protection mechanism to reduce the memory overhead per search request if the potential number of shards in the request can be large.',
|
||||
type: 'number',
|
||||
default: 512,
|
||||
},
|
||||
ccs_minimize_roundtrips: {
|
||||
description:
|
||||
'Indicates whether network round-trips should be minimized as part of cross-cluster search requests execution.',
|
||||
type: 'boolean',
|
||||
default: true,
|
||||
},
|
||||
default_operator: {
|
||||
description: 'The default operator for query string query (AND or OR).',
|
||||
enum: ['AND', 'OR'],
|
||||
type: 'string',
|
||||
default: 'OR',
|
||||
},
|
||||
df: {
|
||||
description:
|
||||
'The field to use as default where no field prefix is given in the query string.',
|
||||
type: 'string',
|
||||
},
|
||||
docvalue_fields: {
|
||||
description:
|
||||
'A comma-separated list of fields to return as the docvalue representation of a field for each hit.',
|
||||
anyOf: [
|
||||
{
|
||||
items: {
|
||||
type: 'string',
|
||||
},
|
||||
type: 'array',
|
||||
},
|
||||
{
|
||||
type: 'string',
|
||||
},
|
||||
],
|
||||
},
|
||||
error_trace: {
|
||||
description: 'Include the stack trace of returned errors.',
|
||||
type: 'boolean',
|
||||
},
|
||||
expand_wildcards: {
|
||||
description:
|
||||
'Whether to expand wildcard expression to concrete indices that are open, closed or both.',
|
||||
enum: ['all', 'closed', 'hidden', 'none', 'open'],
|
||||
type: 'string',
|
||||
default: 'open',
|
||||
},
|
||||
explain: {
|
||||
description:
|
||||
'Specify whether to return detailed information about score computation as part of a hit.',
|
||||
type: 'boolean',
|
||||
},
|
||||
from: {
|
||||
description: 'Starting offset.',
|
||||
type: 'number',
|
||||
default: 0,
|
||||
},
|
||||
human: {
|
||||
description: 'Return human readable values for statistics.',
|
||||
type: 'boolean',
|
||||
default: true,
|
||||
},
|
||||
ignore_throttled: {
|
||||
description:
|
||||
'Whether specified concrete, expanded or aliased indices should be ignored when throttled.',
|
||||
type: 'boolean',
|
||||
},
|
||||
ignore_unavailable: {
|
||||
description:
|
||||
'Whether specified concrete indices should be ignored when unavailable (missing or closed)',
|
||||
type: 'boolean',
|
||||
},
|
||||
index: {
|
||||
description:
|
||||
'A comma-separated list of index names to search; use _all or empty string to perform the operation on all indices.',
|
||||
anyOf: [
|
||||
{
|
||||
items: {
|
||||
type: 'string',
|
||||
},
|
||||
type: 'array',
|
||||
},
|
||||
{
|
||||
type: 'string',
|
||||
},
|
||||
],
|
||||
examples: ['', '_all', 'my_index'],
|
||||
},
|
||||
lenient: {
|
||||
description:
|
||||
'Specify whether format-based query failures (such as providing text to a numeric field) should be ignored.',
|
||||
type: 'boolean',
|
||||
},
|
||||
max_concurrent_shard_requests: {
|
||||
description:
|
||||
'The number of concurrent shard requests per node this search executes concurrently. This value should be used to limit the impact of the search on the cluster in order to limit the number of concurrent shard requests.',
|
||||
type: 'number',
|
||||
default: 5,
|
||||
},
|
||||
min_compatible_shard_node: {
|
||||
description:
|
||||
'The minimum compatible version that all shards involved in search should have for this request to be successful.',
|
||||
type: 'string',
|
||||
},
|
||||
pre_filter_shard_size: {
|
||||
description:
|
||||
'A threshold that enforces a pre-filter roundtrip to prefilter search shards based on query rewriting if the number of shards the search request expands to exceeds the threshold. This filter roundtrip can limit the number of shards significantly if for instance a shard can not match any documents based on its rewrite method ie. if date filters are mandatory to match but the shard bounds and the query are disjoint.',
|
||||
type: 'number',
|
||||
},
|
||||
preference: {
|
||||
description: 'Specify the node or shard the operation should be performed on.',
|
||||
type: 'string',
|
||||
default: 'random',
|
||||
},
|
||||
pretty: {
|
||||
description: 'Pretty format the returned JSON response.',
|
||||
type: 'boolean',
|
||||
},
|
||||
q: {
|
||||
description: 'Query in the Lucene query string syntax.',
|
||||
type: 'string',
|
||||
},
|
||||
request_cache: {
|
||||
description:
|
||||
'Specify if request cache should be used for this request or not, defaults to index level setting.',
|
||||
type: 'boolean',
|
||||
},
|
||||
rest_total_hits_as_int: {
|
||||
description:
|
||||
'Indicates whether hits.total should be rendered as an integer or an object in the rest search response.',
|
||||
type: 'boolean',
|
||||
},
|
||||
routing: {
|
||||
description: 'A comma-separated list of specific routing values.',
|
||||
anyOf: [
|
||||
{
|
||||
items: {
|
||||
type: 'string',
|
||||
},
|
||||
type: 'array',
|
||||
},
|
||||
{
|
||||
type: 'string',
|
||||
},
|
||||
],
|
||||
},
|
||||
scroll: {
|
||||
description:
|
||||
'Specify how long a consistent view of the index should be maintained for scrolled search.',
|
||||
type: 'string',
|
||||
},
|
||||
search_type: {
|
||||
description: 'Search operation type.',
|
||||
enum: ['dfs_query_then_fetch', 'query_then_fetch'],
|
||||
type: 'string',
|
||||
},
|
||||
seq_no_primary_term: {
|
||||
description:
|
||||
'Specify whether to return sequence number and primary term of the last modification of each hit',
|
||||
type: 'boolean',
|
||||
},
|
||||
size: {
|
||||
description: 'Number of hits to return.',
|
||||
type: 'number',
|
||||
default: 10,
|
||||
},
|
||||
sort: {
|
||||
description: 'A comma-separated list of <field>:<direction> pairs.',
|
||||
examples: ['name:asc', ['rating:asc', 'created_at:desc']],
|
||||
anyOf: [
|
||||
{
|
||||
items: {
|
||||
type: 'string',
|
||||
},
|
||||
type: 'array',
|
||||
},
|
||||
{
|
||||
type: 'string',
|
||||
},
|
||||
],
|
||||
},
|
||||
source: {
|
||||
description:
|
||||
'The URL-encoded request definition. Useful for libraries that do not accept a request body for non-POST requests.',
|
||||
type: 'string',
|
||||
},
|
||||
stats: {
|
||||
description: 'Specific tag of the request for logging and statistical purposes',
|
||||
anyOf: [
|
||||
{
|
||||
items: {
|
||||
type: 'string',
|
||||
},
|
||||
type: 'array',
|
||||
},
|
||||
{
|
||||
type: 'string',
|
||||
},
|
||||
],
|
||||
},
|
||||
stored_fields: {
|
||||
description: 'A comma-separated list of stored fields to return as part of a hit',
|
||||
anyOf: [
|
||||
{
|
||||
items: {
|
||||
type: 'string',
|
||||
},
|
||||
type: 'array',
|
||||
},
|
||||
{
|
||||
type: 'string',
|
||||
},
|
||||
],
|
||||
},
|
||||
suggest_field: {
|
||||
description: 'Specify which field to use for suggestions',
|
||||
type: 'string',
|
||||
},
|
||||
suggest_mode: {
|
||||
description: 'Specify suggest mode',
|
||||
enum: ['always', 'missing', 'popular'],
|
||||
type: 'string',
|
||||
default: 'missing',
|
||||
},
|
||||
suggest_size: {
|
||||
description: 'How many suggestions to return in response',
|
||||
type: 'number',
|
||||
},
|
||||
suggest_text: {
|
||||
description: 'The source text for which the suggestions should be returned.',
|
||||
type: 'string',
|
||||
},
|
||||
terminate_after: {
|
||||
description:
|
||||
'The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early.',
|
||||
type: 'number',
|
||||
},
|
||||
timeout: {
|
||||
description: 'Explicit operation timeout.',
|
||||
type: 'string',
|
||||
},
|
||||
track_scores: {
|
||||
description: 'Whether to calculate and return scores even if they are not used for sorting.',
|
||||
type: 'boolean',
|
||||
},
|
||||
track_total_hits: {
|
||||
description: 'Indicate if the number of documents that match the query should be tracked.',
|
||||
type: 'boolean',
|
||||
},
|
||||
type: {
|
||||
description:
|
||||
'A comma-separated list of document types to search; leave empty to perform the operation on all types.',
|
||||
anyOf: [
|
||||
{
|
||||
items: {
|
||||
type: 'string',
|
||||
},
|
||||
type: 'array',
|
||||
},
|
||||
{
|
||||
type: 'string',
|
||||
},
|
||||
],
|
||||
},
|
||||
typed_keys: {
|
||||
description:
|
||||
'Specify whether aggregation and suggester names should be prefixed by their respective types in the response.',
|
||||
type: 'boolean',
|
||||
},
|
||||
version: {
|
||||
description: 'Specify whether to return document version as part of a hit',
|
||||
type: 'boolean',
|
||||
},
|
||||
},
|
||||
definitions: {
|
||||
Query: {
|
||||
description:
|
||||
'A query expressed in the Elasticsearch query DSL. See https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl.html.',
|
||||
type: 'object',
|
||||
additionalProperties: true,
|
||||
},
|
||||
},
|
||||
errorMessage: {
|
||||
type: 'ElasticsearchSearch request properties should be an object.',
|
||||
},
|
||||
};
|
@ -15,8 +15,9 @@
|
||||
*/
|
||||
|
||||
import { Client } from '@elastic/elasticsearch';
|
||||
import schema from './schema.js';
|
||||
|
||||
async function elasticsearchUpdate({ request, connection }) {
|
||||
async function ElasticsearchUpdate({ request, connection }) {
|
||||
const client = new Client(connection);
|
||||
|
||||
const { body: response } = await client.update({
|
||||
@ -30,4 +31,10 @@ async function elasticsearchUpdate({ request, connection }) {
|
||||
};
|
||||
}
|
||||
|
||||
export default elasticsearchUpdate;
|
||||
ElasticsearchUpdate.schema = schema;
|
||||
ElasticsearchUpdate.meta = {
|
||||
checkRead: false,
|
||||
checkWrite: true,
|
||||
};
|
||||
|
||||
export default ElasticsearchUpdate;
|
||||
|
@ -1,187 +0,0 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"title": "Lowdefy Request Schema - ElasticsearchUpdate",
|
||||
"type": "object",
|
||||
"description": "Updates a document using the specified script.",
|
||||
"required": [
|
||||
"id",
|
||||
"body"
|
||||
],
|
||||
"properties": {
|
||||
"id": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"type": "number"
|
||||
}
|
||||
],
|
||||
"description": "Unique identifier for the document to be updated."
|
||||
},
|
||||
"index": {
|
||||
"type": "string",
|
||||
"description": "Name of the target index. By default, the index is created automatically if it doesn't exist. For more information, see Automatically create data streams and indices."
|
||||
},
|
||||
"if_seq_no": {
|
||||
"type": "integer",
|
||||
"description": "Only perform the operation if the document has this sequence number. See Optimistic concurrency control."
|
||||
},
|
||||
"if_primary_term": {
|
||||
"type": "integer",
|
||||
"description": "Only perform the operation if the document has this primary term. See Optimistic concurrency control."
|
||||
},
|
||||
"require_alias": {
|
||||
"type": "boolean",
|
||||
"description": "If true, the destination must be an index alias. Defaults to false.",
|
||||
"default": false
|
||||
},
|
||||
"refresh": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"type": "boolean"
|
||||
}
|
||||
],
|
||||
"description": "If true, Elasticsearch refreshes the affected shards to make this operation visible to search, if wait_for then wait for a refresh to make this operation visible to search, if false do nothing with refreshes. Valid values: true, false, wait_for. Default: false.",
|
||||
"enum": [
|
||||
"true",
|
||||
"false",
|
||||
true,
|
||||
false,
|
||||
"wait_for"
|
||||
],
|
||||
"default": false
|
||||
},
|
||||
"retry_on_conflict": {
|
||||
"type": "integer",
|
||||
"description": "Specify how many times should the operation be retried when a conflict occurs. Default: 0.",
|
||||
"default": 0
|
||||
},
|
||||
"routing": {
|
||||
"description": "Custom value used to route operations to a specific shard.",
|
||||
"type": "string"
|
||||
},
|
||||
"_source": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"type": "array"
|
||||
}
|
||||
],
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": "Set to false to disable source retrieval (default: true). You can also specify a comma-separated list of the fields you want to retrieve.",
|
||||
"default": true
|
||||
},
|
||||
"_source_excludes": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": "Specify the source fields you want to exclude."
|
||||
},
|
||||
"_source_includes": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": "Specify the source fields you want to include."
|
||||
},
|
||||
"timeout": {
|
||||
"type": "string",
|
||||
"description": "Period to wait for the following operations:\n\nDynamic mapping updates\nWaiting for active shards\nDefaults to 1m (one minute). This guarantees Elasticsearch waits for at least the timeout before failing. The actual wait time could be longer, particularly when multiple waits occur.",
|
||||
"default": "1m"
|
||||
},
|
||||
"wait_for_active_shards": {
|
||||
"type": "string",
|
||||
"description": "The number of shard copies that must be active before proceeding with the operation. Set to all or any positive integer up to the total number of shards in the index (number_of_replicas+1). Default: 1, the primary shard.",
|
||||
"default": "1"
|
||||
},
|
||||
"body": {
|
||||
"description": "The request definition requires either script or partial doc.",
|
||||
"anyOf": [
|
||||
{
|
||||
"required": [
|
||||
"doc"
|
||||
]
|
||||
},
|
||||
{
|
||||
"required": [
|
||||
"script"
|
||||
]
|
||||
}
|
||||
],
|
||||
"properties": {
|
||||
"doc": {
|
||||
"additionalProperties": true,
|
||||
"description": "Partial document to update"
|
||||
},
|
||||
"script": {
|
||||
"$ref": "#/definitions/Script"
|
||||
}
|
||||
},
|
||||
"errorMessage": {
|
||||
"anyOf": "ElasticsearchUpdate request should have required property \"body.doc\" or \"body.script\"."
|
||||
}
|
||||
}
|
||||
},
|
||||
"definitions": {
|
||||
"Script": {
|
||||
"description": "An Elasticsearch script.",
|
||||
"additionalProperties": false,
|
||||
"anyOf": [
|
||||
{
|
||||
"required": [
|
||||
"source"
|
||||
]
|
||||
},
|
||||
{
|
||||
"required": [
|
||||
"id"
|
||||
]
|
||||
}
|
||||
],
|
||||
"properties": {
|
||||
"lang": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"painless",
|
||||
"expression",
|
||||
"mustache",
|
||||
"java"
|
||||
],
|
||||
"description": "Specifies the language the script is written in. Defaults to painless.",
|
||||
"default": "painless"
|
||||
},
|
||||
"source": {
|
||||
"description": "The script itself, which you specify as source for an inline script.",
|
||||
"type": "string"
|
||||
},
|
||||
"id": {
|
||||
"description": "The script itself, which you specify as id for a stored script. Use the stored script APIs to create and manage stored scripts.",
|
||||
"type": "string"
|
||||
},
|
||||
"params": {
|
||||
"description": "Specifies any named parameters that are passed into the script as variables. Use parameters instead of hard-coded values to decrease compile time.",
|
||||
"type": "object"
|
||||
}
|
||||
},
|
||||
"errorMessage": {
|
||||
"anyOf": "ElasticsearchUpdate request should have required property \"body.script.source\" or \"body.script.id\"."
|
||||
}
|
||||
}
|
||||
},
|
||||
"errorMessage": {
|
||||
"type": "ElasticsearchUpdate request properties should be an object.",
|
||||
"required": {
|
||||
"id": "ElasticsearchUpdate request should have required property \"id\".",
|
||||
"body": "ElasticsearchUpdate request should have required property \"body\"."
|
||||
}
|
||||
}
|
||||
}
|
@ -17,11 +17,10 @@
|
||||
import { Client } from '@elastic/elasticsearch';
|
||||
import { validate } from '@lowdefy/ajv';
|
||||
|
||||
import elasticsearchUpdate from './ElasticsearchUpdate.js';
|
||||
import requestIndex from './index.js';
|
||||
import schema from './ElasticsearchUpdate.json';
|
||||
import ElasticsearchUpdate from './ElasticsearchUpdate.js';
|
||||
|
||||
const { checkRead, checkWrite } = requestIndex.meta;
|
||||
const { checkRead, checkWrite } = ElasticsearchUpdate.meta;
|
||||
const schema = ElasticsearchUpdate.schema;
|
||||
|
||||
const mockElasticsearchClient = jest.fn(() => mockElasticsearchClient);
|
||||
mockElasticsearchClient.update = jest.fn(() => mockElasticsearchClient);
|
||||
@ -128,7 +127,7 @@ test('ElasticsearchUpdate', async () => {
|
||||
},
|
||||
},
|
||||
};
|
||||
const res = await elasticsearchUpdate({ request, connection });
|
||||
const res = await ElasticsearchUpdate({ request, connection });
|
||||
expect(Client.mock.calls).toEqual([
|
||||
[
|
||||
{
|
||||
|
@ -1,26 +0,0 @@
|
||||
/*
|
||||
Copyright 2020-2021 Lowdefy, Inc
|
||||
|
||||
Licensed 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.
|
||||
*/
|
||||
|
||||
export default {
|
||||
import: {
|
||||
path: 'connections/Elasticsearch/ElasticsearchUpdate/ElasticsearchUpdate.js',
|
||||
schema: 'connections/Elasticsearch/ElasticsearchUpdate/ElasticsearchUpdate.json',
|
||||
},
|
||||
meta: {
|
||||
checkRead: false,
|
||||
checkWrite: true,
|
||||
},
|
||||
};
|
@ -0,0 +1,193 @@
|
||||
/*
|
||||
Copyright 2020-2021 Lowdefy, Inc
|
||||
|
||||
Licensed 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.
|
||||
*/
|
||||
|
||||
export default {
|
||||
$schema: 'http://json-schema.org/draft-07/schema#',
|
||||
title: 'Lowdefy Request Schema - ElasticsearchUpdate',
|
||||
type: 'object',
|
||||
description: 'Updates a document using the specified script.',
|
||||
required: ['id', 'body'],
|
||||
properties: {
|
||||
id: {
|
||||
anyOf: [
|
||||
{
|
||||
type: 'string',
|
||||
},
|
||||
{
|
||||
type: 'number',
|
||||
},
|
||||
],
|
||||
description: 'Unique identifier for the document to be updated.',
|
||||
},
|
||||
index: {
|
||||
type: 'string',
|
||||
description:
|
||||
"Name of the target index. By default, the index is created automatically if it doesn't exist. For more information, see Automatically create data streams and indices.",
|
||||
},
|
||||
if_seq_no: {
|
||||
type: 'integer',
|
||||
description:
|
||||
'Only perform the operation if the document has this sequence number. See Optimistic concurrency control.',
|
||||
},
|
||||
if_primary_term: {
|
||||
type: 'integer',
|
||||
description:
|
||||
'Only perform the operation if the document has this primary term. See Optimistic concurrency control.',
|
||||
},
|
||||
require_alias: {
|
||||
type: 'boolean',
|
||||
description: 'If true, the destination must be an index alias. Defaults to false.',
|
||||
default: false,
|
||||
},
|
||||
refresh: {
|
||||
anyOf: [
|
||||
{
|
||||
type: 'string',
|
||||
},
|
||||
{
|
||||
type: 'boolean',
|
||||
},
|
||||
],
|
||||
description:
|
||||
'If true, Elasticsearch refreshes the affected shards to make this operation visible to search, if wait_for then wait for a refresh to make this operation visible to search, if false do nothing with refreshes. Valid values: true, false, wait_for. Default: false.',
|
||||
enum: ['true', 'false', true, false, 'wait_for'],
|
||||
default: false,
|
||||
},
|
||||
retry_on_conflict: {
|
||||
type: 'integer',
|
||||
description:
|
||||
'Specify how many times should the operation be retried when a conflict occurs. Default: 0.',
|
||||
default: 0,
|
||||
},
|
||||
routing: {
|
||||
description: 'Custom value used to route operations to a specific shard.',
|
||||
type: 'string',
|
||||
},
|
||||
_source: {
|
||||
anyOf: [
|
||||
{
|
||||
type: 'boolean',
|
||||
},
|
||||
{
|
||||
type: 'array',
|
||||
},
|
||||
],
|
||||
items: {
|
||||
type: 'string',
|
||||
},
|
||||
description:
|
||||
'Set to false to disable source retrieval (default: true). You can also specify a comma-separated list of the fields you want to retrieve.',
|
||||
default: true,
|
||||
},
|
||||
_source_excludes: {
|
||||
type: 'array',
|
||||
items: {
|
||||
type: 'string',
|
||||
},
|
||||
description: 'Specify the source fields you want to exclude.',
|
||||
},
|
||||
_source_includes: {
|
||||
type: 'array',
|
||||
items: {
|
||||
type: 'string',
|
||||
},
|
||||
description: 'Specify the source fields you want to include.',
|
||||
},
|
||||
timeout: {
|
||||
type: 'string',
|
||||
description:
|
||||
'Period to wait for the following operations:\n\nDynamic mapping updates\nWaiting for active shards\nDefaults to 1m (one minute). This guarantees Elasticsearch waits for at least the timeout before failing. The actual wait time could be longer, particularly when multiple waits occur.',
|
||||
default: '1m',
|
||||
},
|
||||
wait_for_active_shards: {
|
||||
type: 'string',
|
||||
description:
|
||||
'The number of shard copies that must be active before proceeding with the operation. Set to all or any positive integer up to the total number of shards in the index (number_of_replicas+1). Default: 1, the primary shard.',
|
||||
default: '1',
|
||||
},
|
||||
body: {
|
||||
description: 'The request definition requires either script or partial doc.',
|
||||
anyOf: [
|
||||
{
|
||||
required: ['doc'],
|
||||
},
|
||||
{
|
||||
required: ['script'],
|
||||
},
|
||||
],
|
||||
properties: {
|
||||
doc: {
|
||||
additionalProperties: true,
|
||||
description: 'Partial document to update',
|
||||
},
|
||||
script: {
|
||||
$ref: '#/definitions/Script',
|
||||
},
|
||||
},
|
||||
errorMessage: {
|
||||
anyOf:
|
||||
'ElasticsearchUpdate request should have required property "body.doc" or "body.script".',
|
||||
},
|
||||
},
|
||||
},
|
||||
definitions: {
|
||||
Script: {
|
||||
description: 'An Elasticsearch script.',
|
||||
additionalProperties: false,
|
||||
anyOf: [
|
||||
{
|
||||
required: ['source'],
|
||||
},
|
||||
{
|
||||
required: ['id'],
|
||||
},
|
||||
],
|
||||
properties: {
|
||||
lang: {
|
||||
type: 'string',
|
||||
enum: ['painless', 'expression', 'mustache', 'java'],
|
||||
description: 'Specifies the language the script is written in. Defaults to painless.',
|
||||
default: 'painless',
|
||||
},
|
||||
source: {
|
||||
description: 'The script itself, which you specify as source for an inline script.',
|
||||
type: 'string',
|
||||
},
|
||||
id: {
|
||||
description:
|
||||
'The script itself, which you specify as id for a stored script. Use the stored script APIs to create and manage stored scripts.',
|
||||
type: 'string',
|
||||
},
|
||||
params: {
|
||||
description:
|
||||
'Specifies any named parameters that are passed into the script as variables. Use parameters instead of hard-coded values to decrease compile time.',
|
||||
type: 'object',
|
||||
},
|
||||
},
|
||||
errorMessage: {
|
||||
anyOf:
|
||||
'ElasticsearchUpdate request should have required property "body.script.source" or "body.script.id".',
|
||||
},
|
||||
},
|
||||
},
|
||||
errorMessage: {
|
||||
type: 'ElasticsearchUpdate request properties should be an object.',
|
||||
required: {
|
||||
id: 'ElasticsearchUpdate request should have required property "id".',
|
||||
body: 'ElasticsearchUpdate request should have required property "body".',
|
||||
},
|
||||
},
|
||||
};
|
@ -15,8 +15,9 @@
|
||||
*/
|
||||
|
||||
import { Client } from '@elastic/elasticsearch';
|
||||
import schema from './schema.js';
|
||||
|
||||
async function elasticsearchUpdateByQuery({ request, connection }) {
|
||||
async function ElasticsearchUpdateByQuery({ request, connection }) {
|
||||
const client = new Client(connection);
|
||||
|
||||
const { body: response } = await client.updateByQuery({
|
||||
@ -29,4 +30,10 @@ async function elasticsearchUpdateByQuery({ request, connection }) {
|
||||
};
|
||||
}
|
||||
|
||||
export default elasticsearchUpdateByQuery;
|
||||
ElasticsearchUpdateByQuery.schema = schema;
|
||||
ElasticsearchUpdateByQuery.meta = {
|
||||
checkRead: false,
|
||||
checkWrite: true,
|
||||
};
|
||||
|
||||
export default ElasticsearchUpdateByQuery;
|
||||
|
@ -1,240 +0,0 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"title": "Lowdefy Request Schema - ElasticsearchUpdateByQuery",
|
||||
"type": "object",
|
||||
"description": "Updates documents that match the specified query. If no query is specified, performs an update on every document in the data stream or index without modifying the source, which is useful for picking up mapping changes.",
|
||||
"properties": {
|
||||
"index": {
|
||||
"type": "string",
|
||||
"description": "The name of the index."
|
||||
},
|
||||
"allow_no_indices": {
|
||||
"type": "boolean",
|
||||
"description": "If false, the request returns an error if any wildcard expression, index alias, or _all value targets only missing or closed indices. This behavior applies even if the request targets other open indices. For example, a request targeting foo*,bar* returns an error if an index starts with foo but no index starts with bar.",
|
||||
"default": true
|
||||
},
|
||||
"analyzer": {
|
||||
"description": "The analyzer to use for the query string.",
|
||||
"type": "string"
|
||||
},
|
||||
"analyze_wildcard": {
|
||||
"description": "Specify whether wildcard and prefix queries should be analyzed.",
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"conflicts": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"abort",
|
||||
"proceed"
|
||||
],
|
||||
"description": "What to do if update by query hits version conflicts: abort or proceed. Defaults to abort.",
|
||||
"default": "abort"
|
||||
},
|
||||
"default_operator": {
|
||||
"description": "The default operator for query string query (AND or OR).",
|
||||
"enum": [
|
||||
"AND",
|
||||
"OR"
|
||||
],
|
||||
"type": "string",
|
||||
"default": "OR"
|
||||
},
|
||||
"df": {
|
||||
"description": "The field to use as default where no field prefix is given in the query string.",
|
||||
"type": "string"
|
||||
},
|
||||
"expand_wildcards": {
|
||||
"description": "Whether to expand wildcard expression to concrete indices that are open, closed or both.",
|
||||
"enum": [
|
||||
"all",
|
||||
"closed",
|
||||
"hidden",
|
||||
"none",
|
||||
"open"
|
||||
],
|
||||
"type": "string",
|
||||
"default": "open"
|
||||
},
|
||||
"from": {
|
||||
"description": "Starting offset.",
|
||||
"type": "number",
|
||||
"default": 0
|
||||
},
|
||||
"ignore_unavailable": {
|
||||
"description": "Whether specified concrete indices should be ignored when unavailable (missing or closed)",
|
||||
"type": "boolean"
|
||||
},
|
||||
"lenient": {
|
||||
"description": "Specify whether format-based query failures (such as providing text to a numeric field) should be ignored.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"max_docs": {
|
||||
"type": "integer",
|
||||
"description": "Maximum number of documents to process. Defaults to all documents."
|
||||
},
|
||||
"pipeline": {
|
||||
"type": "string",
|
||||
"description": "ID of the pipeline to use to preprocess incoming documents."
|
||||
},
|
||||
"preference": {
|
||||
"description": "Specify the node or shard the operation should be performed on.",
|
||||
"type": "string",
|
||||
"default": "random"
|
||||
},
|
||||
"pretty": {
|
||||
"description": "Pretty format the returned JSON response.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"q": {
|
||||
"description": "Query in the Lucene query string syntax.",
|
||||
"type": "string"
|
||||
},
|
||||
"request_cache": {
|
||||
"description": "Specify if request cache should be used for this request or not, defaults to index level setting.",
|
||||
"type": "boolean"
|
||||
},
|
||||
"refresh": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"type": "boolean"
|
||||
}
|
||||
],
|
||||
"description": "If true, Elasticsearch refreshes all shards involved in the delete by query after the request completes. Defaults to false.",
|
||||
"enum": [
|
||||
"true",
|
||||
"false",
|
||||
true,
|
||||
false,
|
||||
"wait_for"
|
||||
],
|
||||
"default": false
|
||||
},
|
||||
"requests_per_second": {
|
||||
"type": "integer",
|
||||
"description": "The throttle for this request in sub-requests per second. Defaults to -1 (no throttle).",
|
||||
"default": -1
|
||||
},
|
||||
"routing": {
|
||||
"type": "string",
|
||||
"description": "Custom value used to route operations to a specific shard."
|
||||
},
|
||||
"scroll": {
|
||||
"type": "string",
|
||||
"description": "Period to retain the search context for scrolling. See Scroll search results."
|
||||
},
|
||||
"scroll_size": {
|
||||
"type": "integer",
|
||||
"description": "Size on the scroll request powering the update by query. Defaults to 100.",
|
||||
"default": 100
|
||||
},
|
||||
"search_type": {
|
||||
"description": "Search operation type.",
|
||||
"enum": [
|
||||
"dfs_query_then_fetch",
|
||||
"query_then_fetch"
|
||||
],
|
||||
"type": "string"
|
||||
},
|
||||
"search_timeout": {
|
||||
"type": "string",
|
||||
"description": "Explicit timeout for each search request. Defaults to no timeout."
|
||||
},
|
||||
"slices": {
|
||||
"type": "integer",
|
||||
"description": "The number of slices this task should be divided into. Defaults to 1 meaning the task isn't sliced into subtasks."
|
||||
},
|
||||
"sort": {
|
||||
"description": "A comma-separated list of <field>:<direction> pairs.",
|
||||
"examples": [
|
||||
"name:asc",
|
||||
[
|
||||
"rating:asc",
|
||||
"created_at:desc"
|
||||
]
|
||||
],
|
||||
"anyOf": [
|
||||
{
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"type": "array"
|
||||
},
|
||||
{
|
||||
"type": "string"
|
||||
}
|
||||
]
|
||||
},
|
||||
"_source": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"type": "array"
|
||||
}
|
||||
],
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": "True or false to return the _source field or not, or a list of fields to return."
|
||||
},
|
||||
"_source_excludes": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": "A comma-separated list of source fields to exclude from the response.\n\nYou can also use this parameter to exclude fields from the subset specified in _source_includes query parameter.\n\nIf the _source parameter is false, this parameter is ignored."
|
||||
},
|
||||
"_source_includes": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": "A comma-separated list of source fields to include in the response.\n\nIf this parameter is specified, only these source fields are returned. You can exclude fields from this subset using the _source_excludes query parameter.\n\nIf the _source parameter is false, this parameter is ignored."
|
||||
},
|
||||
"stats": {
|
||||
"description": "Specific tag of the request for logging and statistical purposes",
|
||||
"anyOf": [
|
||||
{
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"type": "array"
|
||||
},
|
||||
{
|
||||
"type": "string"
|
||||
}
|
||||
]
|
||||
},
|
||||
"terminate_after": {
|
||||
"description": "The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early. Elasticsearch collects documents before sorting.\nUse with caution. Elasticsearch applies this parameter to each shard handling the request. When possible, let Elasticsearch perform early termination automatically. Avoid specifying this parameter for requests that target data streams with backing indices across multiple data tiers.",
|
||||
"type": "number"
|
||||
},
|
||||
"timeout": {
|
||||
"type": "string",
|
||||
"description": "Period each deletion request waits for active shards. Defaults to 1m (one minute).",
|
||||
"default": "1m"
|
||||
},
|
||||
"version": {
|
||||
"description": "Explicit version number for concurrency control. The specified version must match the current version of the document for the request to succeed.",
|
||||
"type": "integer"
|
||||
},
|
||||
"wait_for_active_shards": {
|
||||
"type": "string",
|
||||
"description": "The number of shard copies that must be active before proceeding with the operation. Set to all or any positive integer up to the total number of shards in the index (number_of_replicas+1). Default: 1, the primary shard.",
|
||||
"default": "1"
|
||||
},
|
||||
"wait_for_completion": {
|
||||
"type": "boolean",
|
||||
"description": "Should the request should block until the update by query operation is complete. Default: true",
|
||||
"default": true
|
||||
}
|
||||
},
|
||||
"errorMessage": {
|
||||
"type": "ElasticsearchDelete request properties should be an object."
|
||||
}
|
||||
}
|
@ -17,11 +17,10 @@
|
||||
import { Client } from '@elastic/elasticsearch';
|
||||
import { validate } from '@lowdefy/ajv';
|
||||
|
||||
import elasticsearchUpdateByQuery from './ElasticsearchUpdateByQuery.js';
|
||||
import requestIndex from './index.js';
|
||||
import schema from './ElasticsearchUpdateByQuery.json';
|
||||
import ElasticsearchUpdateByQuery from './ElasticsearchUpdateByQuery.js';
|
||||
|
||||
const { checkRead, checkWrite } = requestIndex.meta;
|
||||
const { checkRead, checkWrite } = ElasticsearchUpdateByQuery.meta;
|
||||
const schema = ElasticsearchUpdateByQuery.schema;
|
||||
|
||||
const mockElasticsearchClient = jest.fn(() => mockElasticsearchClient);
|
||||
mockElasticsearchClient.updateByQuery = jest.fn(() => mockElasticsearchClient);
|
||||
@ -82,7 +81,7 @@ test('ElasticsearchUpdateByQuery', async () => {
|
||||
},
|
||||
},
|
||||
};
|
||||
const res = await elasticsearchUpdateByQuery({ request, connection });
|
||||
const res = await ElasticsearchUpdateByQuery({ request, connection });
|
||||
expect(Client.mock.calls).toEqual([
|
||||
[
|
||||
{
|
||||
|
@ -1,26 +0,0 @@
|
||||
/*
|
||||
Copyright 2020-2021 Lowdefy, Inc
|
||||
|
||||
Licensed 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.
|
||||
*/
|
||||
|
||||
export default {
|
||||
import: {
|
||||
path: 'connections/Elasticsearch/ElasticsearchUpdateByQuery/ElasticsearchUpdateByQuery.js',
|
||||
schema: 'connections/Elasticsearch/ElasticsearchUpdateByQuery/ElasticsearchUpdateByQuery.json',
|
||||
},
|
||||
meta: {
|
||||
checkRead: false,
|
||||
checkWrite: true,
|
||||
},
|
||||
};
|
@ -0,0 +1,248 @@
|
||||
/*
|
||||
Copyright 2020-2021 Lowdefy, Inc
|
||||
|
||||
Licensed 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.
|
||||
*/
|
||||
|
||||
export default {
|
||||
$schema: 'http://json-schema.org/draft-07/schema#',
|
||||
title: 'Lowdefy Request Schema - ElasticsearchUpdateByQuery',
|
||||
type: 'object',
|
||||
description:
|
||||
'Updates documents that match the specified query. If no query is specified, performs an update on every document in the data stream or index without modifying the source, which is useful for picking up mapping changes.',
|
||||
properties: {
|
||||
index: {
|
||||
type: 'string',
|
||||
description: 'The name of the index.',
|
||||
},
|
||||
allow_no_indices: {
|
||||
type: 'boolean',
|
||||
description:
|
||||
'If false, the request returns an error if any wildcard expression, index alias, or _all value targets only missing or closed indices. This behavior applies even if the request targets other open indices. For example, a request targeting foo*,bar* returns an error if an index starts with foo but no index starts with bar.',
|
||||
default: true,
|
||||
},
|
||||
analyzer: {
|
||||
description: 'The analyzer to use for the query string.',
|
||||
type: 'string',
|
||||
},
|
||||
analyze_wildcard: {
|
||||
description: 'Specify whether wildcard and prefix queries should be analyzed.',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
},
|
||||
conflicts: {
|
||||
type: 'string',
|
||||
enum: ['abort', 'proceed'],
|
||||
description:
|
||||
'What to do if update by query hits version conflicts: abort or proceed. Defaults to abort.',
|
||||
default: 'abort',
|
||||
},
|
||||
default_operator: {
|
||||
description: 'The default operator for query string query (AND or OR).',
|
||||
enum: ['AND', 'OR'],
|
||||
type: 'string',
|
||||
default: 'OR',
|
||||
},
|
||||
df: {
|
||||
description:
|
||||
'The field to use as default where no field prefix is given in the query string.',
|
||||
type: 'string',
|
||||
},
|
||||
expand_wildcards: {
|
||||
description:
|
||||
'Whether to expand wildcard expression to concrete indices that are open, closed or both.',
|
||||
enum: ['all', 'closed', 'hidden', 'none', 'open'],
|
||||
type: 'string',
|
||||
default: 'open',
|
||||
},
|
||||
from: {
|
||||
description: 'Starting offset.',
|
||||
type: 'number',
|
||||
default: 0,
|
||||
},
|
||||
ignore_unavailable: {
|
||||
description:
|
||||
'Whether specified concrete indices should be ignored when unavailable (missing or closed)',
|
||||
type: 'boolean',
|
||||
},
|
||||
lenient: {
|
||||
description:
|
||||
'Specify whether format-based query failures (such as providing text to a numeric field) should be ignored.',
|
||||
type: 'boolean',
|
||||
},
|
||||
max_docs: {
|
||||
type: 'integer',
|
||||
description: 'Maximum number of documents to process. Defaults to all documents.',
|
||||
},
|
||||
pipeline: {
|
||||
type: 'string',
|
||||
description: 'ID of the pipeline to use to preprocess incoming documents.',
|
||||
},
|
||||
preference: {
|
||||
description: 'Specify the node or shard the operation should be performed on.',
|
||||
type: 'string',
|
||||
default: 'random',
|
||||
},
|
||||
pretty: {
|
||||
description: 'Pretty format the returned JSON response.',
|
||||
type: 'boolean',
|
||||
},
|
||||
q: {
|
||||
description: 'Query in the Lucene query string syntax.',
|
||||
type: 'string',
|
||||
},
|
||||
request_cache: {
|
||||
description:
|
||||
'Specify if request cache should be used for this request or not, defaults to index level setting.',
|
||||
type: 'boolean',
|
||||
},
|
||||
refresh: {
|
||||
anyOf: [
|
||||
{
|
||||
type: 'string',
|
||||
},
|
||||
{
|
||||
type: 'boolean',
|
||||
},
|
||||
],
|
||||
description:
|
||||
'If true, Elasticsearch refreshes all shards involved in the delete by query after the request completes. Defaults to false.',
|
||||
enum: ['true', 'false', true, false, 'wait_for'],
|
||||
default: false,
|
||||
},
|
||||
requests_per_second: {
|
||||
type: 'integer',
|
||||
description:
|
||||
'The throttle for this request in sub-requests per second. Defaults to -1 (no throttle).',
|
||||
default: -1,
|
||||
},
|
||||
routing: {
|
||||
type: 'string',
|
||||
description: 'Custom value used to route operations to a specific shard.',
|
||||
},
|
||||
scroll: {
|
||||
type: 'string',
|
||||
description: 'Period to retain the search context for scrolling. See Scroll search results.',
|
||||
},
|
||||
scroll_size: {
|
||||
type: 'integer',
|
||||
description: 'Size on the scroll request powering the update by query. Defaults to 100.',
|
||||
default: 100,
|
||||
},
|
||||
search_type: {
|
||||
description: 'Search operation type.',
|
||||
enum: ['dfs_query_then_fetch', 'query_then_fetch'],
|
||||
type: 'string',
|
||||
},
|
||||
search_timeout: {
|
||||
type: 'string',
|
||||
description: 'Explicit timeout for each search request. Defaults to no timeout.',
|
||||
},
|
||||
slices: {
|
||||
type: 'integer',
|
||||
description:
|
||||
"The number of slices this task should be divided into. Defaults to 1 meaning the task isn't sliced into subtasks.",
|
||||
},
|
||||
sort: {
|
||||
description: 'A comma-separated list of <field>:<direction> pairs.',
|
||||
examples: ['name:asc', ['rating:asc', 'created_at:desc']],
|
||||
anyOf: [
|
||||
{
|
||||
items: {
|
||||
type: 'string',
|
||||
},
|
||||
type: 'array',
|
||||
},
|
||||
{
|
||||
type: 'string',
|
||||
},
|
||||
],
|
||||
},
|
||||
_source: {
|
||||
anyOf: [
|
||||
{
|
||||
type: 'boolean',
|
||||
},
|
||||
{
|
||||
type: 'array',
|
||||
},
|
||||
],
|
||||
items: {
|
||||
type: 'string',
|
||||
},
|
||||
description:
|
||||
'True or false to return the _source field or not, or a list of fields to return.',
|
||||
},
|
||||
_source_excludes: {
|
||||
type: 'array',
|
||||
items: {
|
||||
type: 'string',
|
||||
},
|
||||
description:
|
||||
'A comma-separated list of source fields to exclude from the response.\n\nYou can also use this parameter to exclude fields from the subset specified in _source_includes query parameter.\n\nIf the _source parameter is false, this parameter is ignored.',
|
||||
},
|
||||
_source_includes: {
|
||||
type: 'array',
|
||||
items: {
|
||||
type: 'string',
|
||||
},
|
||||
description:
|
||||
'A comma-separated list of source fields to include in the response.\n\nIf this parameter is specified, only these source fields are returned. You can exclude fields from this subset using the _source_excludes query parameter.\n\nIf the _source parameter is false, this parameter is ignored.',
|
||||
},
|
||||
stats: {
|
||||
description: 'Specific tag of the request for logging and statistical purposes',
|
||||
anyOf: [
|
||||
{
|
||||
items: {
|
||||
type: 'string',
|
||||
},
|
||||
type: 'array',
|
||||
},
|
||||
{
|
||||
type: 'string',
|
||||
},
|
||||
],
|
||||
},
|
||||
terminate_after: {
|
||||
description:
|
||||
'The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early. Elasticsearch collects documents before sorting.\nUse with caution. Elasticsearch applies this parameter to each shard handling the request. When possible, let Elasticsearch perform early termination automatically. Avoid specifying this parameter for requests that target data streams with backing indices across multiple data tiers.',
|
||||
type: 'number',
|
||||
},
|
||||
timeout: {
|
||||
type: 'string',
|
||||
description:
|
||||
'Period each deletion request waits for active shards. Defaults to 1m (one minute).',
|
||||
default: '1m',
|
||||
},
|
||||
version: {
|
||||
description:
|
||||
'Explicit version number for concurrency control. The specified version must match the current version of the document for the request to succeed.',
|
||||
type: 'integer',
|
||||
},
|
||||
wait_for_active_shards: {
|
||||
type: 'string',
|
||||
description:
|
||||
'The number of shard copies that must be active before proceeding with the operation. Set to all or any positive integer up to the total number of shards in the index (number_of_replicas+1). Default: 1, the primary shard.',
|
||||
default: '1',
|
||||
},
|
||||
wait_for_completion: {
|
||||
type: 'boolean',
|
||||
description:
|
||||
'Should the request should block until the update by query operation is complete. Default: true',
|
||||
default: true,
|
||||
},
|
||||
},
|
||||
errorMessage: {
|
||||
type: 'ElasticsearchDelete request properties should be an object.',
|
||||
},
|
||||
};
|
@ -0,0 +1,460 @@
|
||||
/*
|
||||
Copyright 2020-2021 Lowdefy, Inc
|
||||
|
||||
Licensed 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.
|
||||
*/
|
||||
|
||||
export default {
|
||||
$schema: 'http://json-schema.org/draft-07/schema#',
|
||||
title: 'Lowdefy Connection Schema - Elasticsearch',
|
||||
type: 'object',
|
||||
properties: {
|
||||
node: {
|
||||
description:
|
||||
'The Elasticsearch endpoint to use. It can be a single string, an array of strings, or an object (or an array of objects) that represents the node',
|
||||
examples: ['http://localhost:9200', 'https://your.node.company.tld:443'],
|
||||
anyOf: [
|
||||
{
|
||||
items: {
|
||||
type: 'string',
|
||||
format: 'uri',
|
||||
pattern: '^(https?)://',
|
||||
},
|
||||
type: 'array',
|
||||
},
|
||||
{
|
||||
$ref: '#/definitions/NodeOptions',
|
||||
},
|
||||
{
|
||||
items: {
|
||||
$ref: '#/definitions/NodeOptions',
|
||||
},
|
||||
type: 'array',
|
||||
},
|
||||
{
|
||||
type: 'string',
|
||||
format: 'uri',
|
||||
pattern: '^(https?)://',
|
||||
},
|
||||
],
|
||||
},
|
||||
nodes: {
|
||||
description:
|
||||
'The Elasticsearch endpoint to use. It can be a single string, an array of strings, or an object (or an array of objects) that represents the node',
|
||||
examples: [
|
||||
{
|
||||
url: 'http://localhost:9200',
|
||||
ssl: 'ssl options',
|
||||
agent: 'http agent options',
|
||||
id: 'custom node id',
|
||||
headers: {
|
||||
'X-Foo': 'Bar',
|
||||
},
|
||||
roles: {
|
||||
master: true,
|
||||
data: true,
|
||||
ingest: true,
|
||||
ml: false,
|
||||
},
|
||||
},
|
||||
'http://localhost:9200',
|
||||
'https://your.node.company.tld:443',
|
||||
],
|
||||
anyOf: [
|
||||
{
|
||||
items: {
|
||||
type: 'string',
|
||||
format: 'uri',
|
||||
pattern: '^(https?)://',
|
||||
},
|
||||
type: 'array',
|
||||
},
|
||||
{
|
||||
$ref: '#/definitions/NodeOptions',
|
||||
},
|
||||
{
|
||||
items: {
|
||||
$ref: '#/definitions/NodeOptions',
|
||||
},
|
||||
type: 'array',
|
||||
},
|
||||
{
|
||||
type: 'string',
|
||||
format: 'uri',
|
||||
pattern: '^(https?)://',
|
||||
},
|
||||
],
|
||||
},
|
||||
index: {
|
||||
description: 'Default index to use for requests.',
|
||||
type: 'string',
|
||||
},
|
||||
auth: {
|
||||
description: 'Your authentication data. You can use both basic authentication and ApiKey.',
|
||||
examples: [
|
||||
{
|
||||
username: 'elastic',
|
||||
password: 'changeMe',
|
||||
},
|
||||
{
|
||||
apiKey: 'base64EncodedApiKey',
|
||||
},
|
||||
],
|
||||
anyOf: [
|
||||
{
|
||||
$ref: '#/definitions/ApiKeyAuth',
|
||||
},
|
||||
{
|
||||
$ref: '#/definitions/BasicAuth',
|
||||
},
|
||||
],
|
||||
errorMessage: {
|
||||
anyOf:
|
||||
'Elasticsearch connection property "auth" should be an object containing credentials',
|
||||
},
|
||||
},
|
||||
maxRetries: {
|
||||
description: 'Max number of retries for each request.',
|
||||
type: 'number',
|
||||
default: 3,
|
||||
minimum: 0,
|
||||
},
|
||||
requestTimeout: {
|
||||
description: 'Max request timeout in milliseconds for each request.',
|
||||
type: 'number',
|
||||
default: 30000,
|
||||
exclusiveMinimum: 0,
|
||||
},
|
||||
pingTimeout: {
|
||||
description: 'Max ping request timeout in milliseconds for each request.',
|
||||
type: 'number',
|
||||
default: 3000,
|
||||
exclusiveMinimum: 0,
|
||||
},
|
||||
sniffInterval: {
|
||||
description:
|
||||
'Perform a sniff operation every n milliseconds. Sniffing might not be the best solution for you, take a look here to know more: https://www.elastic.co/blog/elasticsearch-sniffing-best-practices-what-when-why-how',
|
||||
type: ['number', 'boolean'],
|
||||
default: false,
|
||||
},
|
||||
sniffOnStart: {
|
||||
description:
|
||||
'Perform a sniff once the client is started. Sniffing might not be the best solution for you, take a look here to know more: https://www.elastic.co/blog/elasticsearch-sniffing-best-practices-what-when-why-how',
|
||||
type: 'boolean',
|
||||
},
|
||||
sniffEndpoint: {
|
||||
description: 'Endpoint to ping during a sniff.',
|
||||
type: 'string',
|
||||
default: '_nodes/_all/http',
|
||||
},
|
||||
sniffOnConnectionFault: {
|
||||
description:
|
||||
'Perform a sniff on connection fault. Sniffing might not be the best solution for you, take a look here to know more: https://www.elastic.co/blog/elasticsearch-sniffing-best-practices-what-when-why-how',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
},
|
||||
resurrectStrategy: {
|
||||
description: 'Configure the node resurrection strategy.',
|
||||
enum: ['none', 'optimistic', 'ping'],
|
||||
type: 'string',
|
||||
default: 'ping',
|
||||
},
|
||||
suggestCompression: {
|
||||
description: 'Adds accept-encoding header to every request.',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
},
|
||||
compression: {
|
||||
description: 'Enables gzip request body compression.',
|
||||
enum: ['gzip'],
|
||||
type: ['string', 'boolean'],
|
||||
default: false,
|
||||
},
|
||||
ssl: {
|
||||
$ref: '#/definitions/ConnectionOptions',
|
||||
},
|
||||
proxy: {
|
||||
description:
|
||||
'If you are using an http(s) proxy, you can put its url here. The client will automatically handle the connection to it.',
|
||||
type: 'string',
|
||||
format: 'uri',
|
||||
pattern: '^(https?)://',
|
||||
examples: ['http://localhost:8080', 'http://user:pwd@localhost:8080'],
|
||||
default: null,
|
||||
},
|
||||
agent: {
|
||||
description:
|
||||
'HTTP agent options. If you want to disable the HTTP agent use entirely (and disable the `keep-alive` feature), set the agent to `false`. See https://nodejs.org/api/http.html#http_new_agent_options.',
|
||||
default: null,
|
||||
examples: [
|
||||
{
|
||||
agent: 'options',
|
||||
},
|
||||
{
|
||||
agent: false,
|
||||
},
|
||||
],
|
||||
anyOf: [
|
||||
{
|
||||
$ref: '#/definitions/AgentOptions',
|
||||
},
|
||||
{
|
||||
enum: [false],
|
||||
type: 'boolean',
|
||||
},
|
||||
{
|
||||
type: 'object',
|
||||
},
|
||||
],
|
||||
},
|
||||
name: {
|
||||
description: 'The name to identify the client instance in the events.',
|
||||
type: 'string',
|
||||
default: 'elasticsearch-js',
|
||||
},
|
||||
opaqueIdPrefix: {
|
||||
description:
|
||||
'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,
|
||||
type: 'string',
|
||||
},
|
||||
headers: {
|
||||
description: 'A set of custom headers to send in every request.',
|
||||
examples: [
|
||||
{
|
||||
'X-Foo': 'Bar',
|
||||
},
|
||||
],
|
||||
type: 'object',
|
||||
default: {},
|
||||
},
|
||||
context: {
|
||||
description:
|
||||
'A custom object that you can use for observability in your events. It will be merged with the API level context option.',
|
||||
type: 'object',
|
||||
default: null,
|
||||
},
|
||||
enableMetaHeader: {
|
||||
description:
|
||||
"If true, adds an header named 'x-elastic-client-meta', containing some minimal telemetry data, such as the client and platform version.",
|
||||
type: 'boolean',
|
||||
default: true,
|
||||
},
|
||||
cloud: {
|
||||
description:
|
||||
'Custom configuration for connecting to Elastic Cloud. See Authentication for more details: https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/auth-reference.html',
|
||||
examples: [
|
||||
{
|
||||
id: 'name:bG9jYWxob3N0JGFiY2QkZWZnaA==',
|
||||
},
|
||||
],
|
||||
properties: {
|
||||
id: {
|
||||
type: 'string',
|
||||
},
|
||||
password: {
|
||||
type: 'string',
|
||||
},
|
||||
username: {
|
||||
type: 'string',
|
||||
},
|
||||
},
|
||||
type: 'object',
|
||||
default: null,
|
||||
},
|
||||
disablePrototypePoisoningProtection: {
|
||||
description:
|
||||
'By the default the client will protect you against prototype poisoning attacks. If needed you can disable prototype poisoning protection entirely or one of the two checks. Read the `secure-json-parse` documentation to learn more: https://github.com/fastify/secure-json-parse',
|
||||
enum: ['constructor', false, 'proto', true],
|
||||
default: false,
|
||||
},
|
||||
read: {
|
||||
type: 'boolean',
|
||||
default: true,
|
||||
description: 'Allow reads from the Elasticsearch index.',
|
||||
errorMessage: {
|
||||
type: 'Elasticsearch connection property "read" should be a boolean.',
|
||||
},
|
||||
},
|
||||
write: {
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
description: 'Allow writes to the Elasticsearch index.',
|
||||
errorMessage: {
|
||||
type: 'Elasticsearch connection property "write" should be a boolean.',
|
||||
},
|
||||
},
|
||||
},
|
||||
definitions: {
|
||||
AgentOptions: {
|
||||
description: 'Set of configurable options to set on the agent.',
|
||||
properties: {
|
||||
keepAlive: {
|
||||
description:
|
||||
'Keep sockets around even when there are no outstanding requests, so they can be used for future requests without having to reestablish a TCP connection. Not to be confused with the `keep-alive` value of the `Connection` header. The `Connection: keep-alive` header is always sent when using an agent except when the `Connection` header is explicitly specified or when the `keepAlive` and `maxSockets` options are respectively set to `false` and `Infinity`, in which case `Connection: close` will be used.',
|
||||
default: false,
|
||||
type: 'boolean',
|
||||
},
|
||||
keepAliveMsecs: {
|
||||
description:
|
||||
'When using the `keepAlive` option, specifies the initial delay for TCP Keep-Alive packets. Ignored when the `keepAlive` option is `false` or `undefined`',
|
||||
type: 'number',
|
||||
default: 1000,
|
||||
},
|
||||
maxFreeSockets: {
|
||||
description:
|
||||
'Maximum number of sockets to leave open in a free state. Only relevant if `keepAlive` is set to `true`',
|
||||
type: 'number',
|
||||
default: 256,
|
||||
},
|
||||
maxSockets: {
|
||||
description:
|
||||
'Maximum number of sockets to allow per host. If the same host opens multiple concurrent connections, each request will use new socket until the `maxSockets` value is reached. If the host attempts to open more connections than `maxSockets`, the additional requests will enter into a pending request queue, and will enter active connection state when an existing connection terminates. This makes sure there are at most maxSockets active connections at any point in time, from a given host.',
|
||||
type: 'number',
|
||||
default: 'Infinity',
|
||||
},
|
||||
},
|
||||
type: 'object',
|
||||
},
|
||||
ApiKeyAuth: {
|
||||
description:
|
||||
'The apiKey parameter can be either a base64 encoded string or an object with the values that you can obtain from the create api key endpoint. If you provide both basic authentication credentials and the ApiKey configuration, the ApiKey takes precedence.',
|
||||
properties: {
|
||||
apiKey: {
|
||||
anyOf: [
|
||||
{
|
||||
properties: {
|
||||
api_key: {
|
||||
type: 'string',
|
||||
},
|
||||
id: {
|
||||
type: 'string',
|
||||
},
|
||||
},
|
||||
type: 'object',
|
||||
},
|
||||
{
|
||||
type: 'string',
|
||||
},
|
||||
],
|
||||
errorMessage: {
|
||||
anyOf:
|
||||
'Elasticsearch API key should be specified as a string, or an object containing Elasticsearch cloud credentials',
|
||||
},
|
||||
},
|
||||
},
|
||||
required: ['apiKey'],
|
||||
type: 'object',
|
||||
},
|
||||
BasicAuth: {
|
||||
properties: {
|
||||
password: {
|
||||
type: 'string',
|
||||
},
|
||||
username: {
|
||||
type: 'string',
|
||||
},
|
||||
},
|
||||
required: ['username'],
|
||||
type: 'object',
|
||||
errorMessage: {
|
||||
required: 'Elasticsearch basic auth credentials must consist of at least a username',
|
||||
},
|
||||
},
|
||||
ConnectionOptions: {
|
||||
description:
|
||||
'http.SecureContextOptions - See node.js SSL configuration: https://nodejs.org/api/tls.html',
|
||||
type: 'object',
|
||||
default: null,
|
||||
},
|
||||
NodeOptions: {
|
||||
examples: [
|
||||
{
|
||||
url: 'http://localhost:9200',
|
||||
ssl: 'ssl options',
|
||||
agent: 'http agent options',
|
||||
id: 'custom node id',
|
||||
headers: {
|
||||
'X-Foo': 'Bar',
|
||||
},
|
||||
roles: {
|
||||
master: true,
|
||||
data: true,
|
||||
ingest: true,
|
||||
ml: false,
|
||||
},
|
||||
},
|
||||
],
|
||||
properties: {
|
||||
agent: {
|
||||
$ref: '#/definitions/AgentOptions',
|
||||
},
|
||||
headers: {
|
||||
type: 'object',
|
||||
examples: [
|
||||
{
|
||||
'X-Foo': 'Bar',
|
||||
},
|
||||
],
|
||||
},
|
||||
id: {
|
||||
type: 'string',
|
||||
},
|
||||
roles: {
|
||||
properties: {
|
||||
data: {
|
||||
type: 'boolean',
|
||||
},
|
||||
ingest: {
|
||||
type: 'boolean',
|
||||
},
|
||||
master: {
|
||||
type: 'boolean',
|
||||
},
|
||||
ml: {
|
||||
type: 'boolean',
|
||||
},
|
||||
},
|
||||
type: 'object',
|
||||
},
|
||||
ssl: {
|
||||
$ref: '#/definitions/ConnectionOptions',
|
||||
},
|
||||
url: {
|
||||
type: 'string',
|
||||
format: 'uri',
|
||||
pattern: '^(https?)://',
|
||||
},
|
||||
},
|
||||
type: 'object',
|
||||
},
|
||||
},
|
||||
oneOf: [
|
||||
{
|
||||
required: ['node'],
|
||||
},
|
||||
{
|
||||
required: ['nodes'],
|
||||
},
|
||||
],
|
||||
errorMessage: {
|
||||
type: 'Elasticsearch connection properties should be an object.',
|
||||
oneOf: 'Elasticsearch connection should have required property "node" or "nodes".',
|
||||
properties: {
|
||||
maxRetries: 'Elasticsearch connection "maxRetries" should be 0 or greater',
|
||||
requestTimeout: 'Elasticsearch connection "requestTimeout" should be 1 or greater',
|
||||
pingTimeout: 'Elasticsearch connection "pingTimeout" should be 1 or greater',
|
||||
index: 'Elasticsearch connection property "index" should be a string',
|
||||
},
|
||||
},
|
||||
};
|
@ -1,7 +0,0 @@
|
||||
import Elasticsearch from './connections/Elasticsearch/Elasticsearch.js';
|
||||
|
||||
export const connections = {
|
||||
Elasticsearch,
|
||||
};
|
||||
|
||||
export default { connections };
|
@ -1,3 +1,4 @@
|
||||
/* eslint-disable import/namespace */
|
||||
/*
|
||||
Copyright 2020-2021 Lowdefy, Inc
|
||||
|
||||
@ -14,13 +15,23 @@
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
import * as connections from './connections.js';
|
||||
|
||||
export default {
|
||||
import: {
|
||||
path: 'connections/Elasticsearch/ElasticsearchDelete/ElasticsearchDelete.js',
|
||||
schema: 'connections/Elasticsearch/ElasticsearchDelete/ElasticsearchDelete.json',
|
||||
},
|
||||
meta: {
|
||||
checkRead: false,
|
||||
checkWrite: true,
|
||||
},
|
||||
connections: Object.keys(connections),
|
||||
requests: Object.keys(connections)
|
||||
.map((connection) => Object.keys(connections[connection].requests))
|
||||
.flat(),
|
||||
};
|
||||
|
||||
// export default {
|
||||
// connections: ['Elasticsearch'],
|
||||
// requests: [
|
||||
// ElasticsearchDelete,
|
||||
// ElasticsearchDeleteByQuery,
|
||||
// ElasticsearchIndex,
|
||||
// ElasticsearchSearch,
|
||||
// ElasticsearchUpdate,
|
||||
// ElasticsearchUpdateByQuery,
|
||||
// ],
|
||||
// };
|
@ -3502,6 +3502,7 @@ __metadata:
|
||||
"@lowdefy/blocks-loaders": 4.0.0-alpha.6
|
||||
"@lowdefy/blocks-markdown": 4.0.0-alpha.6
|
||||
"@lowdefy/connection-axios-http": 4.0.0-alpha.6
|
||||
"@lowdefy/connection-elasticsearch": 4.0.0-alpha.6
|
||||
"@lowdefy/connection-redis": 4.0.0-alpha.6
|
||||
"@lowdefy/helpers": 4.0.0-alpha.6
|
||||
"@lowdefy/node-utils": 4.0.0-alpha.6
|
||||
@ -3541,7 +3542,7 @@ __metadata:
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
"@lowdefy/connection-elasticsearch@workspace:packages/plugins/connections/connection-elasticsearch":
|
||||
"@lowdefy/connection-elasticsearch@4.0.0-alpha.6, @lowdefy/connection-elasticsearch@workspace:packages/plugins/connections/connection-elasticsearch":
|
||||
version: 0.0.0-use.local
|
||||
resolution: "@lowdefy/connection-elasticsearch@workspace:packages/plugins/connections/connection-elasticsearch"
|
||||
dependencies:
|
||||
|
Loading…
x
Reference in New Issue
Block a user