ReferenceAsk
Remy Reference/agent/dataSources.count
?

dataSources.count

Counts the chunks in the corpus that match a filter, without returning them.
DataSource.count(filter?) → { chunks: number, latencyMs: number }

Returns how many chunks match a filter, without fetching any, in the same grammar search narrows by: metadata, entities, words, or an exact phrase. It is the cheap way to size a corpus or a subset before a search or a bulk removal.

Parameters
filter
SearchFilter
Which chunks to count: metadata, entities, contains, phrase. No filter counts the whole corpus.
Size a subset
const { chunks } = await Docs.count({ metadata: { department: 'legal' } });
const about = await Docs.count({ entities: ['P-101A'] });