diff --git a/services/search/pkg/bleve/geo_kql_test.go b/services/search/pkg/bleve/geo_kql_test.go deleted file mode 100644 index 5e9c887561..0000000000 --- a/services/search/pkg/bleve/geo_kql_test.go +++ /dev/null @@ -1,59 +0,0 @@ -package bleve_test - -import ( - bleveSearch "github.com/blevesearch/bleve/v2" - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" - - qbleve "github.com/opencloud-eu/opencloud/services/search/pkg/query/bleve" -) - -var _ = Describe("Geo KQL predicates", func() { - // Nuremberg-ish point indexed by geoFixture (see geo_verify_test.go). - const lat, lon = 49.48675890884328, 11.103870357204285 - - // hits compiles the KQL query through the full bleve pipeline and searches a - // fresh fixture holding the single point above. - hits := func(kqlQuery string) int { - q, err := qbleve.DefaultCreator.Create(kqlQuery) - Expect(err).ToNot(HaveOccurred()) - res, err := geoFixture(lon, lat, 1047.7).Search(bleveSearch.NewSearchRequest(q)) - Expect(err).ToNot(HaveOccurred()) - return len(res.Hits) - } - - DescribeTable("geo.distance matches within the radius and misses outside", - func(kqlQuery string, want int) { - Expect(hits(kqlQuery)).To(Equal(want)) - }, - Entry("near", "location:geo.distance(49.48675890884328, 11.103870357204285, 10km)", 1), - Entry("far (Berlin, ~400km)", "location:geo.distance(52.520008, 13.404954, 10km)", 0), - ) - - It("geo.bbox matches a box around the point and misses a distant box", func() { - Expect(hits("location:geo.bbox(49.0, 11.0, 50.0, 12.0)")).To(Equal(1)) - Expect(hits("location:geo.bbox(52.0, 13.0, 53.0, 14.0)")).To(Equal(0)) - }) - - It("geo.polygon matches a polygon around the point and misses a distant one", func() { - Expect(hits("location:geo.polygon(49.0 11.0, 50.0 11.0, 50.0 12.0, 49.0 12.0)")).To(Equal(1)) - Expect(hits("location:geo.polygon(52.0 13.0, 53.0 13.0, 53.0 14.0, 52.0 14.0)")).To(Equal(0)) - }) - - It("composes with other predicates via AND", func() { - near := "location:geo.distance(49.48675890884328, 11.103870357204285, 10km)" - Expect(hits(near + " AND location:geo.bbox(49.0, 11.0, 50.0, 12.0)")).To(Equal(1)) - Expect(hits(near + " AND location:geo.bbox(52.0, 13.0, 53.0, 14.0)")).To(Equal(0)) - }) - - It("matches a bbox given with inverted latitude order", func() { - // Latitude args inverted (max, ..., min): normalised centrally so bleve - // gets a well-formed box instead of erroring. Same box as the passing case. - Expect(hits("location:geo.bbox(50.0, 11.0, 49.0, 12.0)")).To(Equal(1)) - }) - - It("rejects a geo predicate on a non-geopoint field", func() { - _, err := qbleve.DefaultCreator.Create("name:geo.distance(48.2, 16.3, 5km)") - Expect(err).To(HaveOccurred()) - }) -}) diff --git a/services/search/pkg/parity/README.md b/services/search/pkg/parity/README.md index 6cd32a775f..1830888394 100644 --- a/services/search/pkg/parity/README.md +++ b/services/search/pkg/parity/README.md @@ -527,6 +527,8 @@ Fixtures: | GEO-06 | `location:geo.polygon(48.3 16.1, 48.3 16.5, 47.9 16.5, 47.9 16.1)` | vienna.txt | vienna.txt | vienna.txt | ✅ | | GEO-07 | `location:geo.distance(0, 0, 20000km)` | berlin.txt, bruck.txt, vienna.txt | berlin.txt, bruck.txt, vienna.txt | berlin.txt, bruck.txt, vienna.txt | ✅ | | GEO-08 | `name:geo.distance(48.2082, 16.3738, 5km)` | bad request | bad request | bad request | ✅ | +| GEO-09 | `location:geo.distance(48.2082, 1...(47.9, 16.1, 48.3, 16.5)` | vienna.txt | vienna.txt | vienna.txt | ✅ | +| GEO-10 | `location:geo.distance(48.2082, 16.3738, 5km) AND name:bruck*` | no match | no match | no match | ✅ | ### scope diff --git a/services/search/pkg/parity/query_geo_test.go b/services/search/pkg/parity/query_geo_test.go index f7be5d962f..09717f8344 100644 --- a/services/search/pkg/parity/query_geo_test.go +++ b/services/search/pkg/parity/query_geo_test.go @@ -35,6 +35,9 @@ func geoGroup() queryGroup { {id: 7, query: `location:geo.distance(0, 0, 20000km)`, want: []string{"vienna.txt", "bruck.txt", "berlin.txt"}}, // geo predicates only apply to geopoint fields, both engines reject the rest {id: 8, query: `name:geo.distance(48.2082, 16.3738, 5km)`, wantBadRequest: true}, + // geo predicates compose with the rest of the query language + {id: 9, query: `location:geo.distance(48.2082, 16.3738, 50km) AND location:geo.bbox(47.9, 16.1, 48.3, 16.5)`, want: []string{"vienna.txt"}}, + {id: 10, query: `location:geo.distance(48.2082, 16.3738, 5km) AND name:bruck*`}, }, } }