AWS Entity Resolution-Beispiele unter Verwendung von SDK für JavaScript (v3) - AWS-SDK-Codebeispiele

Weitere AWS-SDK-Beispiele sind im GitHub-Repository Beispiele für AWS Doc SDKs verfügbar.

AWS Entity Resolution-Beispiele unter Verwendung von SDK für JavaScript (v3)

Die folgenden Codebeispiele zeigen, wie Sie Aktionen durchführen und gängige Szenarien implementieren, indem Sie AWS SDK für JavaScript (v3) mit AWS Entity Resolution nutzen.

Aktionen sind Codeauszüge aus größeren Programmen und müssen im Kontext ausgeführt werden. Während Aktionen Ihnen zeigen, wie Sie einzelne Servicefunktionen aufrufen, können Sie Aktionen im Kontext der zugehörigen Szenarien anzeigen.

Jedes Beispiel enthält einen Link zum vollständigen Quellcode, wo Sie Anweisungen zum Einrichten und Ausführen des Codes im Kodex finden.

Erste Schritte

Die folgenden Codebeispiele zeigen, wie Sie mit der Verwendung von AWS Entity Resolution beginnen.

SDK für JavaScript (v3)
Anmerkung

Auf GitHub finden Sie noch mehr. Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das AWS-Codebeispiel-Repository einrichten und ausführen.

import { fileURLToPath } from "node:url"; import { EntityResolutionClient, ListMatchingWorkflowsCommand, } from "@aws-sdk/client-entityresolution"; export const main = async () => { const region = "eu-west-1"; const erClient = new EntityResolutionClient({ region: region }); try { const command = new ListMatchingWorkflowsCommand({}); const response = await erClient.send(command); const workflowSummaries = response.workflowSummaries; for (const workflowSummary of workflowSummaries) { console.log(`Attribute name: ${workflowSummaries[0].workflowName} `); } if (workflowSummaries.length === 0) { console.log("No matching workflows found."); } } catch (error) { console.error( `An error occurred in listing the workflow summaries: ${error.message} \n Exiting program.`, ); return; } };
  • Weitere API-Informationen finden Sie unter ListMatchingWorkflows in der AWS SDK für JavaScript-API-Referenz.

Themen

Aktionen

Die folgenden Codebeispiele zeigen, wie CreateMatchingWorkflow verwendet wird.

SDK für JavaScript (v3)
Anmerkung

Auf GitHub finden Sie noch mehr. Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das AWS-Codebeispiel-Repository einrichten und ausführen.

//The default inputs for this demo are read from the ../inputs.json. import { fileURLToPath } from "node:url"; import { CreateMatchingWorkflowCommand, EntityResolutionClient, } from "@aws-sdk/client-entityresolution"; import data from "../inputs.json" with { type: "json" }; const region = "eu-west-1"; const erClient = new EntityResolutionClient({ region: region }); export const main = async () => { const createMatchingWorkflowParams = { roleArn: `${data.inputs.roleArn}`, workflowName: `${data.inputs.workflowName}`, description: "Created by using the AWS SDK for JavaScript (v3).", inputSourceConfig: [ { inputSourceARN: `${data.inputs.JSONinputSourceARN}`, schemaName: `${data.inputs.schemaNameJson}`, applyNormalization: false, }, { inputSourceARN: `${data.inputs.CSVinputSourceARN}`, schemaName: `${data.inputs.schemaNameCSV}`, applyNormalization: false, }, ], outputSourceConfig: [ { outputS3Path: `s3://${data.inputs.myBucketName}/eroutput`, output: [ { name: "id", }, { name: "name", }, { name: "email", }, { name: "phone", }, ], applyNormalization: false, }, ], resolutionTechniques: { resolutionType: "ML_MATCHING" }, }; try { const command = new CreateMatchingWorkflowCommand( createMatchingWorkflowParams, ); const response = await erClient.send(command); console.log( `Workflow created successfully.\n The workflow ARN is: ${response.workflowArn}`, ); } catch (caught) { console.error(caught.message); throw caught; } };
  • Weitere API-Informationen finden Sie unter CreateMatchingWorkflow in der AWS SDK für JavaScript-API-Referenz.

Die folgenden Codebeispiele zeigen, wie CreateSchemaMapping verwendet wird.

SDK für JavaScript (v3)
Anmerkung

Auf GitHub finden Sie noch mehr. Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das AWS-Codebeispiel-Repository einrichten und ausführen.

//The default inputs for this demo are read from the ../inputs.json. import { fileURLToPath } from "node:url"; import { CreateSchemaMappingCommand, EntityResolutionClient, } from "@aws-sdk/client-entityresolution"; import data from "../inputs.json" with { type: "json" }; const region = "eu-west-1"; const erClient = new EntityResolutionClient({ region: region }); export const main = async () => { const createSchemaMappingParamsJson = { schemaName: `${data.inputs.schemaNameJson}`, mappedInputFields: [ { fieldName: "id", type: "UNIQUE_ID", }, { fieldName: "name", type: "NAME", }, { fieldName: "email", type: "EMAIL_ADDRESS", }, ], }; const createSchemaMappingParamsCSV = { schemaName: `${data.inputs.schemaNameCSV}`, mappedInputFields: [ { fieldName: "id", type: "UNIQUE_ID", }, { fieldName: "name", type: "NAME", }, { fieldName: "email", type: "EMAIL_ADDRESS", }, { fieldName: "phone", type: "PROVIDER_ID", subType: "STRING", }, ], }; try { const command = new CreateSchemaMappingCommand( createSchemaMappingParamsJson, ); const response = await erClient.send(command); console.log("The JSON schema mapping name is ", response.schemaName); } catch (error) { console.log("error ", error.message); } };
  • Weitere API-Informationen finden Sie unter CreateSchemaMapping in der AWS SDK für JavaScript-API-Referenz.

Die folgenden Codebeispiele zeigen, wie DeleteMatchingWorkflow verwendet wird.

SDK für JavaScript (v3)
Anmerkung

Auf GitHub finden Sie noch mehr. Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das AWS-Codebeispiel-Repository einrichten und ausführen.

//The default inputs for this demo are read from the ../inputs.json. import { fileURLToPath } from "node:url"; import { DeleteMatchingWorkflowCommand, EntityResolutionClient, } from "@aws-sdk/client-entityresolution"; import data from "../inputs.json" with { type: "json" }; const region = "eu-west-1"; const erClient = new EntityResolutionClient({ region: region }); export const main = async () => { try { const deleteWorkflowParams = { workflowName: `${data.inputs.workflowName}`, }; const command = new DeleteMatchingWorkflowCommand(deleteWorkflowParams); const response = await erClient.send(command); console.log("Workflow deleted successfully!", response); } catch (error) { console.log("error ", error); } };
  • Weitere API-Informationen finden Sie unter DeleteMatchingWorkflow in der AWS SDK für JavaScript-API-Referenz.

Die folgenden Codebeispiele zeigen, wie DeleteSchemaMapping verwendet wird.

SDK für JavaScript (v3)
Anmerkung

Auf GitHub finden Sie noch mehr. Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das AWS-Codebeispiel-Repository einrichten und ausführen.

//The default inputs for this demo are read from the ../inputs.json. import { fileURLToPath } from "node:url"; import { DeleteSchemaMappingCommand, EntityResolutionClient, } from "@aws-sdk/client-entityresolution"; import data from "../inputs.json" with { type: "json" }; const region = "eu-west-1"; const erClient = new EntityResolutionClient({ region: region }); export const main = async () => { const deleteSchemaMapping = { schemaName: `${data.inputs.schemaNameJson}`, }; try { const command = new DeleteSchemaMappingCommand(deleteSchemaMapping); const response = await erClient.send(command); console.log("Schema mapping deleted successfully. ", response); } catch (error) { console.log("error ", error); } };
  • Weitere API-Informationen finden Sie unter DeleteSchemaMapping in der AWS SDK für JavaScript-API-Referenz.

Die folgenden Codebeispiele zeigen, wie GetMatchingJob verwendet wird.

SDK für JavaScript (v3)
Anmerkung

Auf GitHub finden Sie noch mehr. Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das AWS-Codebeispiel-Repository einrichten und ausführen.

//The default inputs for this demo are read from the ../inputs.json. import { fileURLToPath } from "node:url"; import { GetMatchingJobCommand, EntityResolutionClient, } from "@aws-sdk/client-entityresolution"; import data from "../inputs.json" with { type: "json" }; const region = "eu-west-1"; const erClient = new EntityResolutionClient({ region: region }); export const main = async () => { async function getInfo() { const getJobInfoParams = { workflowName: `${data.inputs.workflowName}`, jobId: `${data.inputs.jobId}`, }; try { const command = new GetMatchingJobCommand(getJobInfoParams); const response = await erClient.send(command); console.log(`Job status: ${response.status}`); } catch (error) { console.log("error ", error.message); } } };
  • Weitere API-Informationen finden Sie unter GetMatchingJob in der AWS SDK für JavaScript-API-Referenz.

Die folgenden Codebeispiele zeigen, wie GetSchemaMapping verwendet wird.

SDK für JavaScript (v3)
Anmerkung

Auf GitHub finden Sie noch mehr. Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das AWS-Codebeispiel-Repository einrichten und ausführen.

//The default inputs for this demo are read from the ../inputs.json. import { fileURLToPath } from "node:url"; import { GetSchemaMappingCommand, EntityResolutionClient, } from "@aws-sdk/client-entityresolution"; import data from "../inputs.json" with { type: "json" }; const region = "eu-west-1"; const erClient = new EntityResolutionClient({ region: region }); export const main = async () => { const getSchemaMappingJsonParams = { schemaName: `${data.inputs.schemaNameJson}`, }; try { const command = new GetSchemaMappingCommand(getSchemaMappingJsonParams); const response = await erClient.send(command); console.log(response); console.log( `Schema mapping for the JSON data:\n ${response.mappedInputFields[0]}`, ); console.log("Schema mapping ARN is: ", response.schemaArn); } catch (caught) { console.error(caught.message); throw caught; } };
  • Weitere API-Informationen finden Sie unter GetSchemaMapping in der AWS SDK für JavaScript-API-Referenz.

Die folgenden Codebeispiele zeigen, wie ListSchemaMappings verwendet wird.

SDK für JavaScript (v3)
Anmerkung

Auf GitHub finden Sie noch mehr. Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das AWS-Codebeispiel-Repository einrichten und ausführen.

//The default inputs for this demo are read from the ../inputs.json. import { fileURLToPath } from "node:url"; import { ListSchemaMappingsCommand, EntityResolutionClient, } from "@aws-sdk/client-entityresolution"; import data from "../inputs.json" with { type: "json" }; const region = "eu-west-1"; const erClient = new EntityResolutionClient({ region: region }); export const main = async () => { async function getInfo() { const listSchemaMappingsParams = { workflowName: `${data.inputs.workflowName}`, jobId: `${data.inputs.jobId}`, }; try { const command = new ListSchemaMappingsCommand(listSchemaMappingsParams); const response = await erClient.send(command); const noOfSchemas = response.schemaList.length; for (let i = 0; i < noOfSchemas; i++) { console.log( `Schema Mapping Name: ${response.schemaList[i].schemaName} `, ); } } catch (caught) { console.error(caught.message); throw caught; } }
  • Weitere API-Informationen finden Sie unter ListSchemaMappings in der AWS SDK für JavaScript-API-Referenz.

Die folgenden Codebeispiele zeigen, wie StartMatchingJob verwendet wird.

SDK für JavaScript (v3)
Anmerkung

Auf GitHub finden Sie noch mehr. Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das AWS-Codebeispiel-Repository einrichten und ausführen.

//The default inputs for this demo are read from the ../inputs.json. import { fileURLToPath } from "node:url"; import { StartMatchingJobCommand, EntityResolutionClient, } from "@aws-sdk/client-entityresolution"; import data from "../inputs.json" with { type: "json" }; const region = "eu-west-1"; const erClient = new EntityResolutionClient({ region: region }); export const main = async () => { const matchingJobOfWorkflowParams = { workflowName: `${data.inputs.workflowName}`, }; try { const command = new StartMatchingJobCommand(matchingJobOfWorkflowParams); const response = await erClient.send(command); console.log(`Job ID: ${response.jobID} \n The matching job was successfully started.`); } catch (caught) { console.error(caught.message); throw caught; } };
  • Weitere API-Informationen finden Sie unter StartMatchingJob in der AWS SDK für JavaScript-API-Referenz.

Die folgenden Codebeispiele zeigen, wie TagResource verwendet wird.

SDK für JavaScript (v3)
Anmerkung

Auf GitHub finden Sie noch mehr. Hier finden Sie das vollständige Beispiel und erfahren, wie Sie das AWS-Codebeispiel-Repository einrichten und ausführen.

//The default inputs for this demo are read from the ../inputs.json. import { fileURLToPath } from "node:url"; import { TagResourceCommand, EntityResolutionClient, } from "@aws-sdk/client-entityresolution"; import data from "../inputs.json" with { type: "json" }; const region = "eu-west-1"; const erClient = new EntityResolutionClient({ region: region }); export const main = async () => { const tagResourceCommandParams = { resourceArn: `${data.inputs.schemaArn}`, tags: { tag1: "tag1Value", tag2: "tag2Value", }, }; try { const command = new TagResourceCommand(tagResourceCommandParams); const response = await erClient.send(command); console.log("Successfully tagged the resource."); } catch (caught) { console.error(caught.message); throw caught; } };
  • Details zu API finden Sie unter TagResource in der AWS SDK für JavaScript-API-Referenz.