mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-12-05 05:43:36 -05:00
fix(graph): answer geohash cells without a filter token
This commit is contained in:
1 parent
b928dc8342
commit
19e332f579
2 files changed
+24
-3
No files matched your search
@@ -151,12 +151,15 @@ func searchAggregationsToLibregraph(in []*searchsvc.AggregationResult, defs []li
|
||||
ranges := libregraphRangesToSearch(def.BucketDefinition.GetRanges())
|
||||
agg.Buckets = make([]libregraph.SearchBucket, 0, len(in[i].GetBuckets()))
|
||||
for _, b := range in[i].GetBuckets() {
|
||||
agg.Buckets = append(agg.Buckets, libregraph.SearchBucket{
|
||||
bucket := libregraph.SearchBucket{
|
||||
Key: libregraph.PtrString(b.GetKey()),
|
||||
Count: libregraph.PtrInt64(b.GetCount()),
|
||||
AggregationFilterToken: libregraph.PtrString(aggregationFilterToken(b.GetKey(), ranges)),
|
||||
LibreGraphSubAggregations: searchAggregationsToLibregraph(b.GetSubAggregations(), def.LibreGraphSubAggregations),
|
||||
})
|
||||
}
|
||||
if def.LibreGraphGeohashDefinition == nil {
|
||||
bucket.AggregationFilterToken = libregraph.PtrString(aggregationFilterToken(b.GetKey(), ranges))
|
||||
}
|
||||
agg.Buckets = append(agg.Buckets, bucket)
|
||||
}
|
||||
out = append(out, agg)
|
||||
}
|
||||
|
||||
@@ -468,6 +468,24 @@ var _ = ginkgo.Describe("SearchQuery", func() {
|
||||
Expect(captured().GetAggregations()[0].GetGeohashDefinition().GetPrecision()).To(Equal(int32(5)))
|
||||
})
|
||||
|
||||
ginkgo.It("answers geohash cells without a filter token, their sub-aggregations with one", func() {
|
||||
g, _ := graphWithAggregations(&searchsvc.AggregationResult{
|
||||
Field: "location",
|
||||
Buckets: []*searchsvc.Bucket{{Key: "u4pru", Count: 2, SubAggregations: []*searchsvc.AggregationResult{
|
||||
{Field: "MimeType", Buckets: []*searchsvc.Bucket{{Key: "image/jpeg", Count: 2}}},
|
||||
}}},
|
||||
})
|
||||
rr := postSearchQuery(g, searchQueryBody(`"aggregations": [{"field": "location", "@libre.graph.geohashDefinition": {"precision": 5},
|
||||
"@libre.graph.subAggregations": [{"field": "mimeType"}]}]`))
|
||||
Expect(rr.Code).To(Equal(http.StatusOK), rr.Body.String())
|
||||
|
||||
cell := hitsContainer(rr).Aggregations[0].Buckets[0]
|
||||
Expect(cell.Key).To(Equal("u4pru"))
|
||||
Expect(cell.Token).To(BeEmpty())
|
||||
Expect(rr.Body.String()).ToNot(ContainSubstring("ǂǂ7534707275"))
|
||||
Expect(cell.SubAggregations[0].Buckets[0].Token).To(Equal(`"ǂǂ696d6167652f6a706567"`))
|
||||
})
|
||||
|
||||
ginkgo.It("rejects an $expand it does not know with 400", func() {
|
||||
req := httptest.NewRequest(http.MethodPost, "/search/query?$expand=thumbnails,permissions", bytes.NewBufferString(searchQueryBody(`"from": 0`)))
|
||||
rr := httptest.NewRecorder()
|
||||
|
||||
Reference in new issue
Block a user