From 7793ff4a3ee130aecbdcbed6eb02c267f37c42a7 Mon Sep 17 00:00:00 2001 From: Dominik Schmidt Date: Fri, 27 Nov 2026 13:35:14 +0100 Subject: [PATCH] test(search): pin the case and order of tag buckets The tag listing relies on them: tags keep their case on both engines (AGG-49), and the merge cuts to the first keys in byte order across spaces. --- services/search/pkg/aggregation/merge_test.go | 10 ++++++++++ services/search/pkg/parity/README.md | 3 ++- services/search/pkg/parity/aggregations_test.go | 5 ++++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/services/search/pkg/aggregation/merge_test.go b/services/search/pkg/aggregation/merge_test.go index 7cea3019be..b436111117 100644 --- a/services/search/pkg/aggregation/merge_test.go +++ b/services/search/pkg/aggregation/merge_test.go @@ -284,6 +284,16 @@ var _ = Describe("Merge and Finalize", func() { Expect(render(got)).To(Equal([]string{"audio.artist Saxon=2"})) }) + It("cuts to the first keys in byte order across spaces, upper case before lower case", func() { + opts := []*searchsvc.AggregationOption{{ + Field: "Tags", Size: 3, + BucketDefinition: &searchsvc.BucketDefinition{SortBy: searchsvc.BucketSortBy_BUCKET_SORT_BY_KEY_AS_STRING}, + }} + a := []*searchsvc.AggregationResult{buckets("Tags", bucket("cherry", 1), bucket("apple", 1), bucket("Banana", 1))} + b := []*searchsvc.AggregationResult{buckets("Tags", bucket("apple", 1), bucket("Apple", 1))} + Expect(render(merged(opts, a, b))).To(Equal([]string{"Tags Apple=1", "Tags Banana=1", "Tags apple=2"})) + }) + It("shapes the buckets of a sub-aggregation by its own definition", func() { opts := []*searchsvc.AggregationOption{{Field: "audio.artist", SubAggregations: []*searchsvc.AggregationOption{{ Field: "audio.album", Size: 2, diff --git a/services/search/pkg/parity/README.md b/services/search/pkg/parity/README.md index 3f2716e935..d2c7680ef8 100644 --- a/services/search/pkg/parity/README.md +++ b/services/search/pkg/parity/README.md @@ -856,7 +856,7 @@ Fixtures: - `b.jpg`, MimeType = image/jpeg - `c.jpg`, MimeType = image/jpeg - `d.jpg`, MimeType = image/jpeg -- `live.txt` +- `live.txt`, Tags = Apple, apple, Banana | Case | Query | expected | bleve | OpenSearch | same? | |---|---|---|---|---|---| @@ -879,6 +879,7 @@ Fixtures: | AGG-20 | `mediatype:audio` reads `album buckets in audio.year ranges in artist buckets` | audio.arti... Steel=2, audio.arti.....1980=0, audio.arti.....1980=2, audio.arti...1980..=0, audio.arti...1980..=3, audio.arti...Bomber=2, audio.arti...Spades=1, audio.artist Motörhead=3, … +1 more | audio.arti... Steel=2, audio.arti.....1980=0, audio.arti.....1980=2, audio.arti...1980..=0, audio.arti...1980..=3, audio.arti...Bomber=2, audio.arti...Spades=1, audio.artist Motörhead=3, … +1 more | audio.arti... Steel=2, audio.arti.....1980=0, audio.arti.....1980=2, audio.arti...1980..=0, audio.arti...1980..=3, audio.arti...Bomber=2, audio.arti...Spades=1, audio.artist Motörhead=3, … +1 more | ✅ | | AGG-21 | `mediatype:image` reads `a metric without a single value has none` | audio.year avg none, audio.year min none, audio.year sum none | audio.year avg none, audio.year min none, audio.year sum none | audio.year avg none, audio.year min none, audio.year sum none | ✅ | | AGG-22 | `mediatype:audio` reads `filtered to the Saxon bucket, as many matches as the bucket counted` | a.mp3, audio.artist Saxon=2, b.mp3 | a.mp3, audio.artist Saxon=2, b.mp3 | a.mp3, audio.artist Saxon=2, b.mp3 | ✅ | +| AGG-49 | `name:live.txt` reads `tags keep their case, Apple and apple are two buckets` | Tags Apple=1, Tags Banana=1, Tags apple=1 | Tags Apple=1, Tags Banana=1, Tags apple=1 | Tags Apple=1, Tags Banana=1, Tags apple=1 | ✅ | | AGG-23 | `mediatype:audio` reads `filtered to saxon, a bucket key matches case-sensitively` | no match | no match | no match | ✅ | | AGG-46 | `mediatype:audio` reads `filtered to a fractional key on a whole-number field, no match and no error` | no match | no match | no match | ✅ | | AGG-24 | `mediatype:audio` reads `filtered to the Saxon or the Motörhead bucket` | a.mp3, b.mp3, c.mp3, d.mp3, e.mp3 | a.mp3, b.mp3, c.mp3, d.mp3, e.mp3 | a.mp3, b.mp3, c.mp3, d.mp3, e.mp3 | ✅ | diff --git a/services/search/pkg/parity/aggregations_test.go b/services/search/pkg/parity/aggregations_test.go index cf53603eff..8d93ab8460 100644 --- a/services/search/pkg/parity/aggregations_test.go +++ b/services/search/pkg/parity/aggregations_test.go @@ -95,7 +95,7 @@ func aggregationFixtures() []search.Resource { photo("c.jpg", "2018-09-01T12:00:00Z"), photo("d.jpg", "2021-08-11T08:00:00Z"), // no audio mime type: stays out of the mediatype:audio cases - fixtureDoc("live.txt", withAudio(&libregraph.Audio{Artist: libregraph.PtrString(`Wh*t? "Live"`)})), + fixtureDoc("live.txt", withAudio(&libregraph.Audio{Artist: libregraph.PtrString(`Wh*t? "Live"`)}), withTags("Apple", "apple", "Banana")), } } @@ -271,6 +271,9 @@ func aggregationCases() []aggCase { filters: []*searchService.AggregationFilter{terms("audio.artist", "Saxon")}, aggs: []*searchService.AggregationOption{{Field: "audio.artist"}}, want: []string{"a.mp3", "b.mp3", "audio.artist Saxon=2"}}, + {id: 49, query: "name:live.txt", reads: "tags keep their case, Apple and apple are two buckets", + aggs: []*searchService.AggregationOption{{Field: "Tags"}}, + want: []string{"Tags Apple=1", "Tags Banana=1", "Tags apple=1"}}, {id: 23, query: "mediatype:audio", reads: "filtered to saxon, a bucket key matches case-sensitively", filters: []*searchService.AggregationFilter{terms("audio.artist", "saxon")}}, {id: 46, query: "mediatype:audio", reads: "filtered to a fractional key on a whole-number field, no match and no error",