Skip to main content
Attach metadata to documents to filter search results and provide citations. Metadata is returned with each search result, so you can display source links or restrict results by user, category, or date.

Adding metadata

Pass metadata in the config object when creating an ingest job.
const job = await ns.ingestion.create({
  payload: {
    type: "FILE",
    fileUrl: "https://example.com/report.pdf",
  },
  config: {
    metadata: {
      department: "engineering",
      year: 2024,
      public: true,
    },
  },
});
Metadata values must be primitive types. Nested objects are not supported.
TypeExample
String"engineering"
Number2024
Booleantrue
Store source URLs and titles in metadata to display references in AI responses. See Citations for implementation examples.
const job = await ns.ingestion.create({
  payload: {
    type: "TEXT",
    text: "Product documentation for the v2.0 release...",
  },
  config: {
    metadata: {
      sourceUrl: "https://example.com/docs/v2",
      title: "v2.0 Release Notes",
    },
  },
});

Filtering by metadata

Use metadata to filter search results. See Filtering for examples including multi-tenant filtering, combining multiple conditions, and more.
const results = await ns.search("quarterly results", {
  filter: {
    department: "engineering",
  },
});

Next steps