Skip to main content
Queries that describe a set of files in Curation. A query is a scope plus a list of conditions, all of which must hold. Build one with Scope and F, and rank a search’s results by similarity with RankBy. A query does nothing on its own: it’s an input to the methods that search, count or link files.
to_dict and from_dict convert a query to and from a JSON-compatible dict, so it can be kept in config. Methods that act on the files a query matches, such as link_query_items(), run as jobs and report on them with QueryItemsJob.

FolderScope Objects

The files in a folder and its subfolders. Create one with folder().

FileNameCondition Objects

A condition on the file name. Create one with F.file_name.

DataTypeCondition Objects

A condition on the file’s data type. Create one with F.data_type.

MimeTypeCondition Objects

A condition on the file’s MIME type. Create one with F.mime_type.

UploadedAtCondition Objects

A condition on when the file was uploaded. Create one with F.uploaded_at.

MetadataCondition Objects

A condition on a key in your organization’s metadata schema. Create one with F.metadata.

MetricCondition Objects

A condition on a metric of the file. Create one with F.metric.

FrameMetadataCondition Objects

A condition on a key of a frame’s metadata. Create one with F.frame.metadata.

FrameMetricCondition Objects

A condition on a metric of a frame. Create one with F.frame.metric.

SimilarToFilesRank Objects

Ranks files by similarity to other files. Create one with similar_to_files().

SimilarToTextRank Objects

Ranks files by similarity to a description. Create one with similar_to_text().

CurationQuery Objects

The files in scope that meet every condition in filters. A query can have at most 64 filters. With no filters, it matches every file. With rank_by, which needs premium access to Index, the query matches only its top_k most similar files, and leaves out files without embeddings. query_storage_items() returns them most similar first.

Scope Objects

Creates the scope of a CurationQuery.

folder

Returns the scope for a folder and its subfolders. Arguments:
  • folder - The folder, or its UUID.
Returns:
  • FolderScope - The scope for that folder.

RankBy Objects

Creates the ranking of a CurationQuery, by similarity on the files’ embeddings. The scope’s top-level folder must be upgraded in Index to compute embeddings.

similar_to_files

Ranks files by similarity to files, 1 to 100 files you can see, and leaves those files out. The query matches the top_k most similar files, 1 to 1,000. Files without embeddings are ignored, so if none of files has one, the query matches no files.

similar_to_text

Ranks files by similarity to a description, such as “a dog on a beach”, of at most 75 tokens. The query matches the top_k most similar files, 1 to 1,000. Searching, counting or linking raises InvalidArgumentsError for longer text.

_FileNameField Objects

eq

Matches files with exactly this name.

is_in

Matches files whose name is one of names.

not_in

Matches files whose name is none of names.

contains_text

Matches files whose name contains text, ignoring case.

not_contains_text

Matches files whose name doesn’t contain text, ignoring case.

_DataTypeField Objects

eq

Matches files of this type.

is_in

Matches files of any of these types.

not_in

Matches files of none of these types.

_MimeTypeField Objects

eq

Matches files with this MIME type, such as image/jpeg.

is_in

Matches files with any of these MIME types.

not_in

Matches files with none of these MIME types.

_UploadedAtField Objects

gte

Matches files uploaded at or after time, which must have a timezone.

lte

Matches files uploaded at or before time, which must have a timezone.

_MetadataField Objects

eq

Matches files whose value for the key is value.

is_in

Matches files whose value for the key is one of values.

not_in

Matches files whose value for the key is none of values.

contains_text

Matches files whose value for the key contains text, ignoring case.

not_contains_text

Matches files whose value for the key doesn’t contain text, ignoring case.

gte

Matches files whose value for the key is bound or more: a number, or a datetime with a timezone.

lte

Matches files whose value for the key is bound or less: a number, or a datetime with a timezone.

_MetricField Objects

gte

Matches files whose metric is bound or more.

lte

Matches files whose metric is bound or less.

_FrameMetadataField Objects

eq

Matches frames whose value for the key is value.

is_in

Matches frames whose value for the key is one of values.

contains_text

Matches frames whose value for the key contains text, ignoring case.

gte

Matches frames whose value for the key is bound or more: a number, or a datetime with a timezone.

lte

Matches frames whose value for the key is bound or less: a number, or a datetime with a timezone.

_FrameMetricField Objects

gte

Matches frames whose metric is bound or more.

lte

Matches frames whose metric is bound or less.

_FrameFields Objects

metadata

A key in your organization’s metadata schema, on a frame.

metric

A metric of a frame.

F Objects

The fields a query can filter on. Each operator returns a condition for filters.
  • F.file_name: eq, is_in and not_in match the whole name. contains_text and not_contains_text match part of it, ignoring case.
  • F.data_type: eq, is_in and not_in, with any StorageItemType except DICOM_FILE.
  • F.mime_type: eq, is_in and not_in, with values such as image/jpeg.
  • F.uploaded_at: gte and lte, each including its bound. Times must have a timezone.
  • F.metadata(key): a key in your organization’s metadata schema, which needs premium access to Index. The key’s type decides its operators: text takes eq, is_in, not_in, contains_text and not_contains_text; enum and uuid take eq, is_in and not_in; number takes eq, gte and lte; datetime takes gte and lte; boolean takes eq. It matches only files that have the key. To filter on a key outside the schema, add it with add_scalar() first.
  • F.metric(name): the file’s size, fileSize, in bytes, with gte and lte. It needs premium access to Index.
  • F.frame.metadata(key): like F.metadata(key), on a frame, without not_in and not_contains_text.
  • F.frame.metric(name): a metric of a frame, with gte and lte. width, height and area are in pixels, and they and aspectRatio are always available. brightness, contrast, sharpness, red, green and blue run from 0 to 1 and need the scope’s top-level folder to be upgraded in Index to compute quality metrics. uniqueness and diversity run from 0 to 1 and need it to compute advanced quality metrics.
A file matches the F.frame conditions when one of its frames meets all of them, and they need premium access to Index. An image’s only frame is the image itself, and files without frames, such as audio files, never match them. Lists must contain between 1 and 1,000 values. Conditions on one field combine, so gte and lte together give a range.

metadata

A key in your organization’s metadata schema.

metric

A metric of the file.

QueryItemsJobState Objects

State of a QueryItemsJob. Values:
  • PENDING: The job hasn’t ended yet. Its processed and total say how far it has got.
  • SUCCEEDED: The job finished, and processed every file.
  • FAILED: The job failed. Files it had already processed stay processed; its error says why.
  • CANCELLED: The job was cancelled before it finished. Files it had already processed stay processed.
  • UNKNOWN: A state this SDK version does not recognize. Upgrade the SDK to see it.

_missing_

Return UNKNOWN for any state added to the platform after this SDK version.

QueryItemsJobFailure Objects

A file that a QueryItemsJob couldn’t process.

reason

Why, as a code such as link_failed.

QueryItemsJobError Objects

Why a QueryItemsJob failed.

code

A code such as link_failed.

QueryItemsJob Objects

A job that acts on the files a query matches, such as linking them to a dataset. Counts are in files.

finished_at

When the job ended, or None until its state is final.

processed

Files the job has processed so far, whether or not it succeeded with them.

total

Files the job will process, or None until it has worked that out.

applied

Files the job processed successfully.

skipped

Files the job left as they were, or None for jobs that don’t report them, such as dataset links.

failed

Files the job couldn’t process.

failures

The first 100 files the job couldn’t process.

error

Why the job failed, once its state is FAILED.