n8n/packages/nodes-base/nodes/ElasticSearch/descriptions/DocumentDescription.ts

671 lines
16 KiB
TypeScript
Raw Normal View History

2021-05-14 07:50:58 -07:00
import {
INodeProperties,
} from 'n8n-workflow';
2021-05-21 05:25:55 -07:00
import * as placeholders from './placeholders';
2021-05-14 07:50:58 -07:00
export const documentOperations = [
{
displayName: 'Operation',
name: 'operation',
type: 'options',
displayOptions: {
show: {
resource: [
'document',
],
},
},
options: [
{
name: 'Delete',
value: 'delete',
},
{
name: 'Get',
value: 'get',
},
{
name: 'Get All',
value: 'getAll',
},
{
name: 'Index',
value: 'index',
},
{
name: 'Update',
value: 'update',
},
],
2021-05-17 06:27:47 -07:00
default: 'delete',
2021-05-14 07:50:58 -07:00
description: 'Operation to perform',
},
] as INodeProperties[];
export const documentFields = [
// ----------------------------------------
2021-05-17 06:27:47 -07:00
// document: delete
2021-05-14 07:50:58 -07:00
// ----------------------------------------
{
displayName: 'Index ID',
name: 'indexId',
2021-05-21 05:25:55 -07:00
description: 'ID of the index containing the document to delete.',
2021-05-14 07:50:58 -07:00
type: 'string',
required: true,
default: '',
displayOptions: {
show: {
resource: [
'document',
],
operation: [
2021-05-17 06:27:47 -07:00
'delete',
2021-05-14 07:50:58 -07:00
],
},
},
},
{
displayName: 'Document ID',
name: 'documentId',
2021-05-17 06:27:47 -07:00
description: 'ID of the document to delete.',
2021-05-14 07:50:58 -07:00
type: 'string',
required: true,
default: '',
displayOptions: {
show: {
resource: [
'document',
],
operation: [
2021-05-17 06:27:47 -07:00
'delete',
2021-05-14 07:50:58 -07:00
],
},
},
},
// ----------------------------------------
2021-05-17 06:27:47 -07:00
// document: get
2021-05-14 07:50:58 -07:00
// ----------------------------------------
{
displayName: 'Index ID',
name: 'indexId',
2021-05-21 05:25:55 -07:00
description: 'ID of the index containing the document to retrieve.',
2021-05-14 07:50:58 -07:00
type: 'string',
required: true,
default: '',
displayOptions: {
show: {
resource: [
'document',
],
operation: [
2021-05-17 06:27:47 -07:00
'get',
2021-05-14 07:50:58 -07:00
],
},
},
},
{
displayName: 'Document ID',
name: 'documentId',
2021-05-17 06:27:47 -07:00
description: 'ID of the document to retrieve.',
2021-05-14 07:50:58 -07:00
type: 'string',
required: true,
default: '',
displayOptions: {
show: {
resource: [
'document',
],
operation: [
2021-05-17 06:27:47 -07:00
'get',
2021-05-14 07:50:58 -07:00
],
},
},
},
{
2021-05-21 05:25:55 -07:00
displayName: 'Additional Fields',
name: 'additionalFields',
type: 'collection',
placeholder: 'Add Field',
default: {},
2021-05-14 07:50:58 -07:00
displayOptions: {
show: {
resource: [
'document',
],
operation: [
2021-05-21 05:25:55 -07:00
'get',
2021-05-14 07:50:58 -07:00
],
},
},
2021-05-21 05:25:55 -07:00
options: [
{
displayName: 'Source',
name: '_source',
description: 'Whether to include the <code>_source</code> field.',
type: 'boolean',
default: false,
},
{
displayName: 'Source Excludes',
name: '_source_excludes',
description: 'Comma-separated list of source fields to exclude from the response. If the <code>_source</code> parameter is false, this parameter is ignored.',
type: 'string',
default: '',
},
{
displayName: 'Source Includes',
name: '_source_includes',
description: 'Comma-separated list of source fields to include in the response. If the <code>_source</code> parameter is false, this parameter is ignored.',
type: 'string',
default: '',
},
{
displayName: 'Stored Fields',
name: 'stored_fields',
description: 'If true, retrieve the document fields stored in the index rather than the document <code>_source</code>. Defaults to false.',
type: 'boolean',
default: false,
},
],
2021-05-14 07:50:58 -07:00
},
2021-05-21 05:25:55 -07:00
// ----------------------------------------
// document: getAll
// ----------------------------------------
2021-05-14 07:50:58 -07:00
{
2021-05-21 05:25:55 -07:00
displayName: 'Index ID',
name: 'indexId',
description: 'ID of the index containing the documents to retrieve.',
type: 'string',
required: true,
default: '',
2021-05-14 07:50:58 -07:00
displayOptions: {
show: {
resource: [
'document',
],
operation: [
'getAll',
],
},
},
},
{
displayName: 'Return All',
name: 'returnAll',
type: 'boolean',
default: false,
description: 'Return all results.',
displayOptions: {
show: {
resource: [
'document',
],
operation: [
'getAll',
],
},
},
},
{
displayName: 'Limit',
name: 'limit',
type: 'number',
default: 50,
description: 'The number of results to return.',
typeOptions: {
minValue: 1,
},
displayOptions: {
show: {
resource: [
'document',
],
operation: [
'getAll',
],
returnAll: [
false,
],
},
},
},
2021-05-21 05:25:55 -07:00
{
displayName: 'Additional Fields',
name: 'additionalFields',
type: 'collection',
placeholder: 'Add Field',
default: {},
displayOptions: {
show: {
resource: [
'document',
],
operation: [
'getAll',
],
},
},
options: [
{
displayName: 'Allow No Indices',
name: 'allow_no_indices',
description: 'If false, return an error if any wildcard expression, index alias, or <code>_all</code> value targets only missing or closed indices. Defaults to true.',
type: 'boolean',
default: true,
},
{
displayName: 'Allow Partial Search Results',
name: 'allow_partial_search_results',
description: 'If true, return partial results if there are shard request timeouts or shard failures.<br>If false, returns an error with no partial results. Defaults to true.',
type: 'boolean',
default: true,
},
{
displayName: 'Batched Reduce Size',
name: 'batched_reduce_size',
description: 'Number of shard results that should be reduced at once on the coordinating node. Defaults to 512.',
type: 'number',
typeOptions: {
minValue: 2,
},
default: 512,
},
{
displayName: 'CCS Minimize Roundtrips',
name: 'ccs_minimize_roundtrips',
description: 'If true, network round-trips between the coordinating node and the remote clusters are minimized when executing cross-cluster search (CCS) requests. Defaults to true.',
type: 'boolean',
default: true,
},
{
displayName: 'Docvalue Fields',
name: 'docvalue_fields',
description: 'Comma-separated list of fields to return as the docvalue representation of a field for each hit.',
type: 'string',
default: '',
},
{
displayName: 'Expand Wildcards',
name: 'expand_wildcards',
description: 'Type of index that wildcard expressions can match. Defaults to <code>open</code>.',
type: 'options',
options: [
{
name: 'All',
value: 'all',
},
{
name: 'Closed',
value: 'closed',
},
{
name: 'Hidden',
value: 'hidden',
},
{
name: 'None',
value: 'none',
},
{
name: 'Open',
value: 'open',
},
],
default: 'all',
},
{
displayName: 'Explain',
name: 'explain',
description: 'If true, return detailed information about score computation as part of a hit. Defaults to false.',
type: 'boolean',
default: false,
},
{
displayName: 'Ignore Throttled',
name: 'ignore_throttled',
description: 'If true, concrete, expanded or aliased indices are ignored when frozen. Defaults to true.',
type: 'boolean',
default: true,
},
{
displayName: 'Ignore Unavailable',
name: 'ignore_unavailable',
description: 'If true, missing or closed indices are not included in the response. Defaults to false.',
type: 'boolean',
default: false,
},
{
displayName: 'Max Concurrent Shard Requests',
name: 'max_concurrent_shard_requests',
description: 'Define the number of concurrent shard requests per node this search executes concurrently. Defaults to 5.',
type: 'number',
default: 5,
},
{
displayName: 'Pre-Filter Shard Size',
name: 'pre_filter_shard_size',
description: 'Define a threshold that enforces a pre-filter roundtrip to prefilter search shards based on query rewriting<br>if the number of shards the search request expands to exceeds the threshold.',
type: 'number',
typeOptions: {
minValue: 1,
},
default: 0,
},
{
displayName: 'Query',
name: 'query',
description: 'Query in the <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl.html" target="_blank">ElasticSearch Query DSL</a>.',
type: 'string',
typeOptions: {
alwaysOpenEditWindow: true,
},
default: '',
placeholder: placeholders.query,
},
{
displayName: 'Request Cache',
name: 'request_cache',
description: 'If true, the caching of search results is enabled for requests where size is 0. See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/shard-request-cache.html" target="_blank">ElasticSearch shard request cache settings</a>.',
type: 'boolean',
default: false,
},
{
displayName: 'Rest Total Hits as Integer',
name: 'rest_total_hits_as_int',
description: 'Whether <code>hits.total</code> should be rendered as an integer or an object in the rest search response. Defaults to false.',
type: 'boolean',
default: false,
},
{
displayName: 'Routing',
name: 'routing',
description: 'Target this primary shard.',
type: 'string',
default: '',
},
{
displayName: 'Search Type',
name: 'search_type',
description: 'How distributed term frequencies are calculated for relevance scoring. Defaults to Query then Fetch.',
type: 'options',
options: [
{
name: 'Query Then Fetch',
value: 'query_then_fetch',
},
{
name: 'DFS Query Then Fetch',
value: 'dfs_query_then_fetch',
},
],
default: 'query_then_fetch',
},
{
displayName: 'Sequence Number and Primary Term',
name: 'seq_no_primary_term',
description: 'If true, return the sequence number and primary term of the last modification of each hit. See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/optimistic-concurrency-control.html" target="_blank">Optimistic concurrency control</a>.',
type: 'boolean',
default: false,
},
{
displayName: 'Size',
name: 'size',
description: 'Define the number of hits to return. Defaults to 10.',
type: 'number',
default: 10,
},
{
displayName: 'Sort',
name: 'sort',
description: 'Comma-separated list of <code>field:direction</code> pairs.',
type: 'string',
default: '',
},
{
displayName: 'Source',
name: '_source',
description: 'Whether to include the <code>_source</code> field.',
type: 'boolean',
default: false,
},
{
displayName: 'Source Excludes',
name: '_source_excludes',
description: 'Comma-separated list of source fields to exclude from the response. If the <code>_source</code> parameter is false, this parameter is ignored.',
type: 'string',
default: '',
},
{
displayName: 'Source Includes',
name: '_source_includes',
description: 'Comma-separated list of source fields to include in the response. If the <code>_source</code> parameter is false, this parameter is ignored.',
type: 'string',
default: '',
},
{
displayName: 'Stats',
name: 'stats',
description: 'Tag of the request for logging and statistical purposes.',
type: 'string',
default: '',
},
{
displayName: 'Stored Fields',
name: 'stored_fields',
description: 'If true, retrieve the document fields stored in the index rather than the document <code>_source</code>. Defaults to false.',
type: 'boolean',
default: false,
},
{
displayName: 'Suggest Field',
name: 'suggest_field',
description: 'Field to use for suggestions.',
type: 'string',
default: '',
},
{
displayName: 'Suggest Text',
name: 'suggest_text',
description: 'Source text for which the suggestions should be returned.',
type: 'string',
default: '',
},
{
displayName: 'Terminate After',
name: 'terminate_after',
description: 'Max number of documents to collect for each shard.',
type: 'number',
default: 0,
},
{
displayName: 'Timeout',
name: 'timeout',
description: 'Period to wait for active shards. Defaults to <code>1m</code> (one minute). See the <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/common-options.html#time-units" target="_blank">ElasticSearch time units reference</a>.',
type: 'string',
default: '1m',
},
{
displayName: 'Track Scores',
name: 'track_scores',
description: 'If true, calculate and return document scores, even if the scores are not used for sorting. Defaults to false.',
type: 'boolean',
default: false,
},
{
displayName: 'Track Total Hits',
name: 'track_total_hits',
description: 'Number of hits matching the query to count accurately. Defaults to 10000.',
type: 'number',
default: 10000,
},
{
displayName: 'Version',
name: 'version',
description: 'If true, return document version as part of a hit. Defaults to false.',
type: 'boolean',
default: false,
},
],
},
2021-05-14 07:50:58 -07:00
// ----------------------------------------
2021-05-17 06:27:47 -07:00
// document: index
2021-05-14 07:50:58 -07:00
// ----------------------------------------
{
displayName: 'Index ID',
name: 'indexId',
2021-05-21 05:25:55 -07:00
description: 'ID of the index to add the document to.',
2021-05-14 07:50:58 -07:00
type: 'string',
required: true,
default: '',
displayOptions: {
show: {
resource: [
'document',
],
operation: [
2021-05-17 06:27:47 -07:00
'index',
2021-05-14 07:50:58 -07:00
],
},
},
},
{
displayName: 'Document ID',
name: 'documentId',
2021-05-21 05:25:55 -07:00
description: 'ID of the document to create and add.',
2021-05-14 07:50:58 -07:00
type: 'string',
required: true,
default: '',
displayOptions: {
show: {
resource: [
'document',
],
operation: [
2021-05-17 06:27:47 -07:00
'index',
2021-05-14 07:50:58 -07:00
],
},
},
},
{
2021-05-21 05:25:55 -07:00
displayName: 'Content',
2021-05-17 06:27:47 -07:00
name: 'field',
description: 'JSON source for the document data.',
2021-05-21 05:25:55 -07:00
type: 'json',
typeOptions: {
alwaysOpenEditWindow: true,
},
2021-05-14 07:50:58 -07:00
required: true,
default: '',
2021-05-21 05:25:55 -07:00
placeholder: placeholders.document,
2021-05-14 07:50:58 -07:00
displayOptions: {
show: {
resource: [
'document',
],
operation: [
2021-05-17 06:27:47 -07:00
'index',
2021-05-14 07:50:58 -07:00
],
},
},
},
2021-05-21 05:25:55 -07:00
{
displayName: 'Additional Fields',
name: 'additionalFields',
type: 'collection',
placeholder: 'Add Field',
default: {},
displayOptions: {
show: {
resource: [
'document',
],
operation: [
'index',
],
},
},
options: [
{
displayName: 'Routing',
name: 'routing',
description: 'Target this primary shard.',
type: 'string',
default: '',
},
{
displayName: 'Timeout',
name: 'timeout',
description: 'Period to wait for active shards. Defaults to <code>1m</code> (one minute). See the <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/common-options.html#time-units" target="_blank">ElasticSearch time units reference</a>.',
type: 'string',
default: '1m',
},
],
},
2021-05-14 07:50:58 -07:00
// ----------------------------------------
2021-05-17 06:27:47 -07:00
// document: update
2021-05-14 07:50:58 -07:00
// ----------------------------------------
{
displayName: 'Index ID',
name: 'indexId',
2021-05-17 06:27:47 -07:00
description: 'ID of the document to update.',
2021-05-14 07:50:58 -07:00
type: 'string',
required: true,
default: '',
displayOptions: {
show: {
resource: [
'document',
],
operation: [
2021-05-17 06:27:47 -07:00
'update',
2021-05-14 07:50:58 -07:00
],
},
},
},
{
displayName: 'Document ID',
name: 'documentId',
2021-05-17 06:27:47 -07:00
description: 'ID of the document to update.',
2021-05-14 07:50:58 -07:00
type: 'string',
required: true,
default: '',
displayOptions: {
show: {
resource: [
'document',
],
operation: [
2021-05-17 06:27:47 -07:00
'update',
2021-05-14 07:50:58 -07:00
],
},
},
},
{
2021-05-17 06:27:47 -07:00
displayName: 'Script',
name: 'script',
2021-05-21 05:25:55 -07:00
description: 'Script to update the document. See the <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-scripting-using.html" target="_blank">ElasticSearch guide to writing scripts</a>.',
2021-05-14 07:50:58 -07:00
type: 'string',
required: true,
default: '',
2021-05-21 05:25:55 -07:00
placeholder: 'ctx._source.my_field = 1',
typeOptions: {
alwaysOpenEditWindow: true,
},
2021-05-14 07:50:58 -07:00
displayOptions: {
show: {
resource: [
'document',
],
operation: [
2021-05-17 06:27:47 -07:00
'update',
2021-05-14 07:50:58 -07:00
],
},
},
},
] as INodeProperties[];