mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
🔨 Clean up details
This commit is contained in:
parent
1ee89639a8
commit
64ce0c6046
|
@ -20,6 +20,10 @@ import {
|
||||||
indexOperations,
|
indexOperations,
|
||||||
} from './descriptions';
|
} from './descriptions';
|
||||||
|
|
||||||
|
import {
|
||||||
|
DocumentGetAllAdditionalFields,
|
||||||
|
} from './types';
|
||||||
|
|
||||||
export class ElasticSearch implements INodeType {
|
export class ElasticSearch implements INodeType {
|
||||||
description: INodeTypeDescription = {
|
description: INodeTypeDescription = {
|
||||||
displayName: 'ElasticSearch',
|
displayName: 'ElasticSearch',
|
||||||
|
@ -132,11 +136,11 @@ export class ElasticSearch implements INodeType {
|
||||||
|
|
||||||
const body = {} as IDataObject;
|
const body = {} as IDataObject;
|
||||||
const qs = {} as IDataObject;
|
const qs = {} as IDataObject;
|
||||||
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
const additionalFields = this.getNodeParameter('additionalFields', i) as DocumentGetAllAdditionalFields;
|
||||||
|
|
||||||
if (Object.keys(additionalFields).length) {
|
if (Object.keys(additionalFields).length) {
|
||||||
const { query, ...rest } = additionalFields;
|
const { query, ...rest } = additionalFields;
|
||||||
Object.assign(body, query);
|
Object.assign(body, JSON.parse(query));
|
||||||
Object.assign(qs, rest);
|
Object.assign(qs, rest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,12 +149,9 @@ export class ElasticSearch implements INodeType {
|
||||||
if (!returnAll) {
|
if (!returnAll) {
|
||||||
qs.size = this.getNodeParameter('limit', 0);
|
qs.size = this.getNodeParameter('limit', 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
responseData = await elasticSearchApiRequest.call(this, 'GET', `/${indexId}/_search`, body, qs);
|
responseData = await elasticSearchApiRequest.call(this, 'GET', `/${indexId}/_search`, body, qs);
|
||||||
responseData = responseData.hits.hits;
|
responseData = responseData.hits.hits;
|
||||||
|
|
||||||
// TODO: Paginate
|
|
||||||
|
|
||||||
} else if (operation === 'index') {
|
} else if (operation === 'index') {
|
||||||
|
|
||||||
// ----------------------------------------
|
// ----------------------------------------
|
||||||
|
|
|
@ -51,7 +51,7 @@ export async function elasticSearchApiRequest(
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
console.log(options);
|
// console.log(options);
|
||||||
return await this.helpers.request(options);
|
return await this.helpers.request(options);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw new NodeApiError(this.getNode(), error);
|
throw new NodeApiError(this.getNode(), error);
|
||||||
|
|
|
@ -352,13 +352,13 @@ export const documentFields = [
|
||||||
typeOptions: {
|
typeOptions: {
|
||||||
minValue: 1,
|
minValue: 1,
|
||||||
},
|
},
|
||||||
default: 0,
|
default: 1,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
displayName: 'Query',
|
displayName: 'Query',
|
||||||
name: '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>.',
|
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',
|
type: 'json',
|
||||||
typeOptions: {
|
typeOptions: {
|
||||||
alwaysOpenEditWindow: true,
|
alwaysOpenEditWindow: true,
|
||||||
},
|
},
|
||||||
|
@ -372,13 +372,6 @@ export const documentFields = [
|
||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
default: false,
|
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',
|
displayName: 'Routing',
|
||||||
name: 'routing',
|
name: 'routing',
|
||||||
|
@ -410,13 +403,6 @@ export const documentFields = [
|
||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
{
|
|
||||||
displayName: 'Size',
|
|
||||||
name: 'size',
|
|
||||||
description: 'Define the number of hits to return. Defaults to 10.',
|
|
||||||
type: 'number',
|
|
||||||
default: 10,
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
displayName: 'Sort',
|
displayName: 'Sort',
|
||||||
name: 'sort',
|
name: 'sort',
|
||||||
|
@ -459,20 +445,6 @@ export const documentFields = [
|
||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
default: false,
|
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',
|
displayName: 'Terminate After',
|
||||||
name: 'terminate_after',
|
name: 'terminate_after',
|
||||||
|
|
|
@ -3,3 +3,33 @@ export type ElasticSearchApiCredentials = {
|
||||||
password: string;
|
password: string;
|
||||||
baseUrl: string;
|
baseUrl: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type DocumentGetAllAdditionalFields = {
|
||||||
|
allow_no_indices: boolean;
|
||||||
|
allow_partial_search_results: boolean;
|
||||||
|
batched_reduce_size: number;
|
||||||
|
ccs_minimize_roundtrips: boolean;
|
||||||
|
docvalue_fields: string;
|
||||||
|
expand_wildcards: 'All' | 'Closed' | 'Hidden' | 'None' | 'Open';
|
||||||
|
explain: boolean;
|
||||||
|
ignore_throttled: boolean;
|
||||||
|
ignore_unavailable: boolean;
|
||||||
|
max_concurrent_shard_requests: number;
|
||||||
|
pre_filter_shard_size: number;
|
||||||
|
query: string;
|
||||||
|
request_cache: boolean;
|
||||||
|
routing: string;
|
||||||
|
search_type: 'query_then_fetch' | 'dfs_query_then_fetch';
|
||||||
|
seq_no_primary_term: boolean;
|
||||||
|
sort: string;
|
||||||
|
_source: boolean;
|
||||||
|
_source_excludes: string;
|
||||||
|
_source_includes: string;
|
||||||
|
stats: string;
|
||||||
|
stored_fields: boolean;
|
||||||
|
terminate_after: boolean;
|
||||||
|
timeout: number;
|
||||||
|
track_scores: boolean;
|
||||||
|
track_total_hits: string;
|
||||||
|
version: boolean;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue