Apply a metadata shape, define custom fields, annotate data elements, and index the fields you want to search and scope by
Metadata is the set of typed fields attached to a datasource’s content. Good metadata sharpens retrieval, and once a field is indexed it becomes a dimension an execution policy can scope a session by. This guide covers the ways to populate metadata and how to index a field so you can filter and govern by it. For the concepts behind metadata and its link to access control, see Datasources.
When your documents fit a familiar domain, a prebuilt shape saves you from defining fields by hand. The catalog ships shapes for common document types, including bibliography, legal, medical, and insurance. Browse it to find a shape and note its model_id.
When no prebuilt shape fits, define the fields yourself. Each field carries a name, a type, and a description that tells the extractor what to capture. Set index to true on a field to make it filterable, which is what lets you search and scope by it later.
from meibel.models import UpdateDatasourceRequest, MetadataConfigRequest, MetadataFieldclient.datasources.update( datasource_id="ds_123", body=UpdateDatasourceRequest( metadata_config=MetadataConfigRequest( type="custom", fields=[ MetadataField( name="product_line", type="string", description="The product line a document covers, e.g. commercial or consumer", index=True, ), MetadataField( name="effective_date", type="datetime", description="The date the document takes effect", index=True, ), ], ), ),)
meibel metadata-configuration update-config ds_123 --data '{ "type": "custom", "fields": [ { "name": "product_line", "type": "string", "description": "The product line a document covers, e.g. commercial or consumer", "index": true }, { "name": "effective_date", "type": "datetime", "description": "The date the document takes effect", "index": true } ]}'
A field’s type is one of string, integer, float, boolean, datetime, uuid, geo, or list[string].
A fixed number of fields can be indexed per data type, so index the fields you most need to filter and scope by. An unindexed field is still extracted and still describes its data, but cannot be filtered on.
Automatic extraction covers most values, but sometimes you know a value the extractor cannot infer, or you need to correct one it got wrong. Set metadata directly on a single data element.
A value you set by hand is preserved when the datasource is re-ingested, so a later ingest keeps your annotation rather than overwriting it with a fresh extraction.
Indexing is what connects metadata to access control. Once a field is indexed, an execution policy can filter on it, so you can hold each session to the slice of data a given user should see. With product_line indexed, a policy can restrict a session to a single line:
A session created with this policy retrieves only documents whose product_line is commercial. A field that was never indexed cannot appear in a filter like this, which is why the fields you choose to index set the boundary of what you can govern. For the steps to create and apply policies, see Managing execution policies.