Skip to content

Commit 4ce5d8a

Browse files
authored
Add strongly-typed aggregate result models and public API enhancements (#265)
1 parent d8d0c59 commit 4ce5d8a

15 files changed

+5529
-5504
lines changed

CHANGELOG.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [Unreleased]
9+
10+
### Added
11+
12+
- **Typed Aggregate Result Accessors**: Added strongly-typed accessor methods to `AggregateResult` and `AggregateGroupByResult.Group` for safer and more convenient access to aggregation properties. See [Aggregate Result Accessors documentation](docs/AGGREGATE_RESULT_ACCESSORS.md) for details.
13+
- Direct accessor methods: `Text()`, `Integer()`, `Number()`, `Boolean()`, `Date()`
14+
- TryGet methods: `TryGetText()`, `TryGetInteger()`, `TryGetNumber()`, `TryGetBoolean()`, `TryGetDate()`, `TryGet<T>()`
15+
- Lambda pattern methods: `Property<T>()`, `Match()`, `Match<TResult>()`
16+
17+
- **Typed Aggregate Results**: Added `ToTyped<T>()` extension method to map aggregate results to strongly-typed objects.
18+
- `AggregateResult<T>` and `AggregateGroupByResult<T>` typed result wrappers
19+
- Suffix-based value extraction: use property names like `PriceSum`, `RatingMean`, `TitleCount` to extract specific values
20+
- Full aggregate type mapping: use `Aggregate.Text`, `Aggregate.Number`, etc. for complete access
21+
- Case-insensitive property name matching
22+
23+
- **MetricsExtractor**: Added `MetricsExtractor.FromType<T>()` to automatically extract `returnMetrics` from a type definition
24+
- Analyzes property types and suffixes to generate the appropriate `Aggregate.Metric[]`
25+
- Combines multiple suffixes for the same field into a single metric
26+
- Works with both full `Aggregate.*` types and suffix-based properties
27+
28+
- **Aggregate Property Analyzer**: Added Roslyn analyzers that validate types used with `ToTyped<T>()`
29+
- WEAVIATE002: Warns when a primitive property lacks a recognized suffix
30+
- WEAVIATE003: Warns when a suffix is used with an incompatible type

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ For more detailed information on specific features, please refer to the official
5151
- **[RBAC API Usage](docs/RBAC_API_USAGE.md)**: Managing users, roles, permissions, and groups
5252
- **[Backup API Usage](docs/BACKUP_API_USAGE.md)**: Creating and restoring backups
5353
- **[Nodes API Usage](docs/NODES_API_USAGE.md)**: Querying cluster node information
54+
- **[Aggregate Result Accessors](docs/AGGREGATE_RESULT_ACCESSORS.md)**: Type-safe access to aggregation results
5455

5556
---
5657

0 commit comments

Comments
 (0)