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.
This commit is contained in:
Dominik Schmidt committed 2026-11-27 16:01:56 +01:00
1 parent 507ee69b24
commit 7793ff4a3e
3 files changed
+16 -2

No files matched your search

@@ -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,
+2 -1
View File
@@ -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 | ✅ |
@@ -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",