Skip to main content
Version: 11.14.0

Labels

The Labels module provides functions to manage labels (tags) on documents. All operations are available through the labels namespace object. Labels can be public or private and can be applied to individual documents or in bulk via a query.

Functions

All functions are accessed via the labels namespace:

import { labels } from '@sinequa/atomic';

labels.getUserRights()

Fetches the current user's rights for label management.

Returns Promise<LabelsRights> — the user's label rights for the current application.

Example

get-user-rights.ts
import { labels } from '@sinequa/atomic';

const rights = await labels.getUserRights();
console.log('Can manage labels:', rights);

labels.add()

Adds one or more labels to specific documents.

Parameters

ParameterTypeRequiredDescription
labelListstring[]Array of label names to add
idsstring[]Array of document IDs to label
publicOnlybooleanIf true, labels are public. Default: true

Returns Promise<void>

Example

add-labels.ts
import { labels } from '@sinequa/atomic';

await labels.add(['important', 'reviewed'], ['doc-id-1', 'doc-id-2']);

labels.remove()

Removes one or more labels from specific documents.

Parameters

ParameterTypeRequiredDescription
labelListstring[]Array of label names to remove
idsstring[]Array of document IDs
publicOnlybooleanIf true, operates on public labels only. Default: true

Returns Promise<void>

Example

remove-labels.ts
import { labels } from '@sinequa/atomic';

await labels.remove(['draft'], ['doc-id-1']);

labels.rename()

Renames one or more labels to a new label name.

Parameters

ParameterTypeRequiredDescription
labelListstring[]Array of label names to rename
newLabelstringThe new label name
publicOnlybooleanIf true, operates on public labels only. Default: true

Returns Promise<void>

Example

rename-labels.ts
import { labels } from '@sinequa/atomic';

await labels.rename(['old-name'], 'new-name');

labels.delete()

Deletes one or more labels entirely.

Parameters

ParameterTypeRequiredDescription
labelListstring[]Array of label names to delete
publicOnlybooleanIf true, deletes public labels only. Default: true

Returns Promise<void>

Example

delete-labels.ts
import { labels } from '@sinequa/atomic';

await labels.delete(['obsolete-label']);

labels.bulkAdd()

Adds labels to all documents matching a query.

Parameters

ParameterTypeRequiredDescription
labelListstring[]Array of labels to add
queryQueryQuery whose matching documents receive the labels
publicOnlybooleanIf true, labels are public. Default: true

Returns Promise<void>

Example

bulk-add-labels.ts
import { labels } from '@sinequa/atomic';

await labels.bulkAdd(['quarterly-review'], { name: '_query', text: 'Q1 2024 report' });

labels.bulkRemove()

Removes labels from all documents matching a query.

Parameters

ParameterTypeRequiredDescription
labelListstring[]Array of labels to remove
queryQueryQuery whose matching documents lose the labels
publicOnlybooleanIf true, operates on public labels only. Default: true

Returns Promise<void>

Example

bulk-remove-labels.ts
import { labels } from '@sinequa/atomic';

await labels.bulkRemove(['draft'], { name: '_query', text: 'published documents' });