Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.moss.dev/llms.txt

Use this file to discover all available pages before exploring further.

@moss-dev/moss / MetadataFilter

Type Alias: MetadataFilter

Composable metadata filter passed to QueryOptions.filter. Metadata filtering narrows query results to only documents whose metadata satisfies the filter. It is evaluated on the loaded (local) index; load the index via loadIndex() before querying.
type MetadataFilter =
  | { field: string; condition: FilterCondition }
  | { $and: MetadataFilter[] }
  | { $or:  MetadataFilter[] };

Shapes

  • Field condition — compare a single metadata field using a FilterCondition operator.
  • $and — logical AND of nested filters; a document must satisfy every entry.
  • $or — logical OR of nested filters; a document must satisfy at least one entry.

Example

import { MossClient } from '@moss-dev/moss';

const client = new MossClient(projectId, projectKey);
await client.loadIndex('products');

const results = await client.query('products', 'running shoes', {
  topK: 5,
  alpha: 0.6,
  filter: {
    $and: [
      { field: 'category', condition: { $eq: 'shoes' } },
      { field: 'price',    condition: { $lt: 100 } },
    ],
  },
});