foundatio-repositories

Query, count, patch, and paginate Elasticsearch data through Foundatio.Repositories abstractions.

2.5k|507|Updated Feb 7, 2014
One-click install
npx skills add https://github.com/exceptionless/Exceptionless --skill foundatio-repositories
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: foundatio-repositories
Source: https://github.com/exceptionless/Exceptionless/tree/main/.agents/skills/foundatio-repositories
Command: npx skills add https://github.com/exceptionless/Exceptionless --skill foundatio-repositories

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Working directly with raw Elasticsearch clients in the Exceptionless codebase leads to inconsistent query patterns, unsafe pagination, and bypassed repository conventions. This Skill guides correct use of Foundatio.Repositories abstractions for everyday data access.

Core Features & Use Cases

  • Filter and Aggregation Queries: Build Lucene-style FilterExpression queries and AggregationsExpression DSL strings (cardinality, terms, date histograms, sum, min, max, avg) with CountAsync and FindAsync.
  • Patching: Apply PartialPatch for field-level updates or ScriptPatch for Painless scripts via PatchAsync and PatchAllAsync, with ImmediateConsistency and notification control options.
  • Deep Pagination: Use SearchAfterPaging with NextPageAsync in do/while loops with cancellation token checks instead of offset-based paging.
  • Use Case: When adding a feature that counts events per stack with a date histogram, use CountAsync with an AggregationsExpression like "cardinality:stack_id date:date~1d" instead of writing a raw IElasticClient search.

Quick Start

Ask the AI to write a repository query that counts events grouped by stack using Foundatio.Repositories instead of raw IElasticClient calls.

Frequently Asked Questions about foundatio-repositories

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I paginate large Elasticsearch result sets with Foundatio.Repositories?

Use SearchAfterPaging with PageLimit on the query options, then iterate with NextPageAsync in a do/while loop. Always check the CancellationToken in the loop condition and never use offset-based paging or while(true) with break.

How do I write aggregation queries with Foundatio.Repositories?

Pass an AggregationsExpression string to CountAsync, such as "cardinality:stack_id terms:type date:date~1d". Read results from the returned CountResult.Aggregations helper using names like cardinality_stack_id or date_date.

When should I use raw IElasticClient instead of repositories?

Reserve raw IElasticClient for migrations or index maintenance that cannot be expressed through repositories. Normal query, count, patch, and delete work should use FindAsync, CountAsync, PatchAllAsync, and RemoveAllAsync.

Does .Index(start, end) work for all repository types?

No. .Index(start, end) only routes to correct daily shards for DailyIndex repositories like IEventRepository. It is a no-op for VersionedIndex repositories such as stacks, projects, organizations, users, and tokens.

How do I update documents in bulk with Foundatio.Repositories?

Use PatchAllAsync with a query filter and a PartialPatch for field-level updates or ScriptPatch for Painless scripts. Pass o => o.ImmediateConsistency() when write-then-read consistency is needed, such as in tests.