Skip to main content

updateEntity()

updateEntity(request: UpdateEntityRequest): Promise<EntityOperationResponse>

Defined in: packages/core/src/document-search/index.ts:646

Update/rename an entity across document chunks

Renames an entity in the document index. The operation can be scoped to specific sources, files, or chunks.

Parameters

ParameterTypeDescription
requestUpdateEntityRequestEntity update request

Returns

Promise<EntityOperationResponse>

Promise resolving to EntityOperationResponse:

  • success - Whether the operation succeeded
  • affectedChunks - Number of chunks updated
  • message - Success or error message

Throws

401 - Not authenticated

Throws

404 - Entity not found

Throws

422 - Validation error

Example

import { updateEntity } from "@cpod/sdk";

// Rename entity globally
const result = await updateEntity({
oldName: "Acme",
newName: "Acme Corporation",
});
console.log(`Updated ${result.affectedChunks} chunks`);

// Rename only in specific source
const scopedResult = await updateEntity({
oldName: "J. Smith",
newName: "John Smith",
sources: ["contracts", "hr_documents"],
});