Add Create Index operation
This commit is contained in:
@@ -2094,6 +2094,43 @@ export class Databricks implements INodeType {
|
||||
json: true,
|
||||
});
|
||||
|
||||
returnData.push({
|
||||
json: response,
|
||||
pairedItem: { item: i },
|
||||
});
|
||||
} else if (resource === 'vectorSearch' && operation === 'createIndex') {
|
||||
const credentials = (await this.getCredentials('databricksApi')) as DatabricksCredentials;
|
||||
const host = credentials.host.replace(/\/$/, '');
|
||||
const indexName = this.getNodeParameter('indexName', i) as string;
|
||||
const endpointName = this.getNodeParameter('endpointName', i) as string;
|
||||
const primaryKey = this.getNodeParameter('primaryKey', i) as string;
|
||||
const indexType = this.getNodeParameter('indexType', i) as string;
|
||||
|
||||
const body: Record<string, unknown> = {
|
||||
name: indexName,
|
||||
endpoint_name: endpointName,
|
||||
primary_key: primaryKey,
|
||||
index_type: indexType,
|
||||
};
|
||||
|
||||
if (indexType === 'DELTA_SYNC') {
|
||||
const raw = this.getNodeParameter('deltaSyncIndexSpec', i) as string;
|
||||
body.delta_sync_index_spec = typeof raw === 'string' ? JSON.parse(raw) : raw;
|
||||
} else if (indexType === 'DIRECT_ACCESS') {
|
||||
const raw = this.getNodeParameter('directAccessIndexSpec', i) as string;
|
||||
body.direct_access_index_spec = typeof raw === 'string' ? JSON.parse(raw) : raw;
|
||||
}
|
||||
|
||||
const response = await this.helpers.httpRequest({
|
||||
method: 'POST',
|
||||
url: `${host}/api/2.0/vector-search/indexes`,
|
||||
headers: {
|
||||
Authorization: `Bearer ${credentials.token}`,
|
||||
},
|
||||
body,
|
||||
json: true,
|
||||
});
|
||||
|
||||
returnData.push({
|
||||
json: response,
|
||||
pairedItem: { item: i },
|
||||
|
||||
@@ -11,6 +11,26 @@ export const vectorSearchOperations: INodeProperties = {
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
name: 'Create Index',
|
||||
value: 'createIndex',
|
||||
description: 'Create a new vector search index',
|
||||
action: 'Create a vector search index',
|
||||
routing: {
|
||||
request: {
|
||||
method: 'POST',
|
||||
url: '/api/2.0/vector-search/indexes',
|
||||
body: {
|
||||
name: '={{$parameter.indexName}}',
|
||||
endpoint_name: '={{$parameter.endpointName}}',
|
||||
primary_key: '={{$parameter.primaryKey}}',
|
||||
index_type: '={{$parameter.indexType}}',
|
||||
delta_sync_index_spec: '={{$parameter.deltaSyncIndexSpec}}',
|
||||
direct_access_index_spec: '={{$parameter.directAccessIndexSpec}}',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'Get Index',
|
||||
value: 'getIndex',
|
||||
|
||||
@@ -9,7 +9,7 @@ export const vectorSearchParameters: INodeProperties[] = [
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['vectorSearch'],
|
||||
operation: ['getIndex', 'queryIndex'],
|
||||
operation: ['getIndex', 'queryIndex', 'createIndex'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
@@ -23,12 +23,91 @@ export const vectorSearchParameters: INodeProperties[] = [
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['vectorSearch'],
|
||||
operation: ['listIndexes'],
|
||||
operation: ['listIndexes', 'createIndex'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
description: 'Name of the vector search endpoint',
|
||||
},
|
||||
{
|
||||
displayName: 'Primary Key',
|
||||
name: 'primaryKey',
|
||||
type: 'string',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['vectorSearch'],
|
||||
operation: ['createIndex'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
placeholder: 'id',
|
||||
description: 'Primary key column of the index',
|
||||
},
|
||||
{
|
||||
displayName: 'Index Type',
|
||||
name: 'indexType',
|
||||
type: 'options',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['vectorSearch'],
|
||||
operation: ['createIndex'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
name: 'Delta Sync',
|
||||
value: 'DELTA_SYNC',
|
||||
description: 'Automatically syncs with a source Delta Table',
|
||||
},
|
||||
{
|
||||
name: 'Direct Access',
|
||||
value: 'DIRECT_ACCESS',
|
||||
description: 'Supports direct read and write of vectors and metadata',
|
||||
},
|
||||
],
|
||||
default: 'DELTA_SYNC',
|
||||
description: 'Type of vector search index to create',
|
||||
},
|
||||
{
|
||||
displayName: 'Delta Sync Index Spec',
|
||||
name: 'deltaSyncIndexSpec',
|
||||
type: 'json',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['vectorSearch'],
|
||||
operation: ['createIndex'],
|
||||
indexType: ['DELTA_SYNC'],
|
||||
},
|
||||
},
|
||||
default:
|
||||
'{\n "source_table": "catalog.schema.table",\n "pipeline_type": "TRIGGERED",\n "embedding_source_columns": [{\n "name": "text",\n "embedding_model_endpoint_name": "e5-small-v2"\n }],\n "columns_to_sync": ["id", "text"]\n}',
|
||||
description: 'Specification for the Delta Sync index',
|
||||
typeOptions: {
|
||||
rows: 8,
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Direct Access Index Spec',
|
||||
name: 'directAccessIndexSpec',
|
||||
type: 'json',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['vectorSearch'],
|
||||
operation: ['createIndex'],
|
||||
indexType: ['DIRECT_ACCESS'],
|
||||
},
|
||||
},
|
||||
default:
|
||||
'{\n "embedding_vector_columns": [{\n "name": "embedding",\n "embedding_dimension": 1536\n }],\n "schema_json": "{}"\n}',
|
||||
description: 'Specification for the Direct Access index',
|
||||
typeOptions: {
|
||||
rows: 6,
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Query Type',
|
||||
name: 'queryType',
|
||||
|
||||
Reference in New Issue
Block a user