Entity matching works on any objects with string fields, so it is not tied to asset-centric resources. To match data modeling instances, pass each node with its space as an extra field: externalId is only unique within a space, and every field of a source or target is returned in the predictions.

Hierarchy

Methods

  • Create entity matcher

    // Match time series to assets, both stored as core data model instances.
    const { items: timeSeries } = await client.instances.list({
    instanceType: 'node',
    sources: [{ source: { type: 'view', space: 'cdf_cdm', externalId: 'CogniteTimeSeries', version: 'v1' } }],
    });
    const { items: assets } = await client.instances.list({
    instanceType: 'node',
    sources: [{ source: { type: 'view', space: 'cdf_cdm', externalId: 'CogniteAsset', version: 'v1' } }],
    });
    // externalId is only unique within a space, so keep the space as an extra field.
    const sources = timeSeries.map((node) => ({
    externalId: node.externalId,
    space: node.space,
    name: String(node.properties?.cdf_cdm?.['CogniteTimeSeries/v1']?.name ?? ''),
    }));
    const targets = assets.map((node) => ({
    externalId: node.externalId,
    space: node.space,
    name: String(node.properties?.cdf_cdm?.['CogniteAsset/v1']?.name ?? ''),
    }));

    const result = await client.entityMatching.create({
    sources,
    targets,
    externalId: 'model123',
    name: 'model123',
    });

    Returns Promise<EntityMatchingCreateResponse>