From 86f0fb654571cebad864f3b675bf3bd40c27ab50 Mon Sep 17 00:00:00 2001 From: rng Date: Tue, 5 May 2026 16:56:52 +1000 Subject: [PATCH 1/2] Change id to uuid as id is now reserve word --- .../core/model/enumeration/CQLFields.java | 2 +- .../core/service/CacheNoLandGeometry.java | 2 +- .../server/core/service/ElasticSearch.java | 2 +- .../aodn/ogcapi/server/common/RestApiTest.java | 18 ++++++++++++++++++ .../server/service/ElasticSearchTest.java | 4 ++-- 5 files changed, 23 insertions(+), 5 deletions(-) diff --git a/server/src/main/java/au/org/aodn/ogcapi/server/core/model/enumeration/CQLFields.java b/server/src/main/java/au/org/aodn/ogcapi/server/core/model/enumeration/CQLFields.java index 7d262a73..f4a5990f 100644 --- a/server/src/main/java/au/org/aodn/ogcapi/server/core/model/enumeration/CQLFields.java +++ b/server/src/main/java/au/org/aodn/ogcapi/server/core/model/enumeration/CQLFields.java @@ -158,7 +158,7 @@ public enum CQLFields implements CQLFieldsInterface { StacBasicField.OrganisationVocabs.displayField, null, null), - id( + uuid( StacBasicField.UUID.searchField, StacBasicField.UUID.displayField, // Make sure if id match, it will show up as the first result diff --git a/server/src/main/java/au/org/aodn/ogcapi/server/core/service/CacheNoLandGeometry.java b/server/src/main/java/au/org/aodn/ogcapi/server/core/service/CacheNoLandGeometry.java index c032c0ac..bfdfbc46 100644 --- a/server/src/main/java/au/org/aodn/ogcapi/server/core/service/CacheNoLandGeometry.java +++ b/server/src/main/java/au/org/aodn/ogcapi/server/core/service/CacheNoLandGeometry.java @@ -34,7 +34,7 @@ public Map getAllNoLandGeometry() { null, null, null, - List.of(CQLFields.id.name(), CQLFields.centroid_nocache.name()), + List.of(CQLFields.uuid.name(), CQLFields.centroid_nocache.name()), null, null, null, diff --git a/server/src/main/java/au/org/aodn/ogcapi/server/core/service/ElasticSearch.java b/server/src/main/java/au/org/aodn/ogcapi/server/core/service/ElasticSearch.java index fdbfb9d8..cd042e43 100644 --- a/server/src/main/java/au/org/aodn/ogcapi/server/core/service/ElasticSearch.java +++ b/server/src/main/java/au/org/aodn/ogcapi/server/core/service/ElasticSearch.java @@ -290,7 +290,7 @@ public ElasticSearchBase.SearchResult searchByParameters(Li should.add(CQLFields.parameter_vocabs.getPropertyEqualToQuery(term)); should.add(CQLFields.organisation_vocabs.getPropertyEqualToQuery(term)); should.add(CQLFields.platform_vocabs.getPropertyEqualToQuery(term)); - should.add(CQLFields.id.getPropertyEqualToQuery(term)); + should.add(CQLFields.uuid.getPropertyEqualToQuery(term)); // A request to not using acronym in title and description in metadata, hence these // acronym moved to links, for example NRMN record is mentioned in the link title. // This is a work-around to the requirement but still allow use of NRMN diff --git a/server/src/test/java/au/org/aodn/ogcapi/server/common/RestApiTest.java b/server/src/test/java/au/org/aodn/ogcapi/server/common/RestApiTest.java index ade0fa54..9e891140 100644 --- a/server/src/test/java/au/org/aodn/ogcapi/server/common/RestApiTest.java +++ b/server/src/test/java/au/org/aodn/ogcapi/server/common/RestApiTest.java @@ -804,4 +804,22 @@ public void verifyIBoundaryFunctionWorks() throws IOException { assertEquals(1, Objects.requireNonNull(collections.getBody()).getCollections().size(), "hit 1"); assertEquals("516811d7-cd1e-207a-e0440003ba8c79dd", Objects.requireNonNull(collections.getBody()).getCollections().get(0).getId(), "id correct"); } + + @Test + public void verifyUUIDSearchWorks() throws IOException { + super.insertJsonToElasticRecordIndex( + // Will hit Shark Bay + "516811d7-cd1e-207a-e0440003ba8c79dd.json", + // Will hit Central Eastern of Auz marine park, but not Shark Bay + "ae86e2f5-eaaf-459e-a405-e654d85adb9c.json" + ); + ResponseEntity collections = testRestTemplate.exchange( + getBasePath() + "/collections?filter=uuid='516811d7-cd1e-207a-e0440003ba8c79dd'", + HttpMethod.GET, + null, + new ParameterizedTypeReference<>() {}); + + assertEquals(1, Objects.requireNonNull(collections.getBody()).getCollections().size(), "hit 1"); + assertEquals("516811d7-cd1e-207a-e0440003ba8c79dd", Objects.requireNonNull(collections.getBody()).getCollections().get(0).getId(), "id correct"); + } } diff --git a/server/src/test/java/au/org/aodn/ogcapi/server/service/ElasticSearchTest.java b/server/src/test/java/au/org/aodn/ogcapi/server/service/ElasticSearchTest.java index 1e849be1..1d6375e4 100644 --- a/server/src/test/java/au/org/aodn/ogcapi/server/service/ElasticSearchTest.java +++ b/server/src/test/java/au/org/aodn/ogcapi/server/service/ElasticSearchTest.java @@ -136,7 +136,7 @@ public void searchByParametersWithDoubleQuote() { should.add(CQLFields.parameter_vocabs.getPropertyEqualToQuery(term)); should.add(CQLFields.organisation_vocabs.getPropertyEqualToQuery(term)); should.add(CQLFields.platform_vocabs.getPropertyEqualToQuery(term)); - should.add(CQLFields.id.getPropertyEqualToQuery(term)); + should.add(CQLFields.uuid.getPropertyEqualToQuery(term)); should.add(BoolQuery.of(b -> b .should(CQLFields.links_title_contains.getPropertyEqualToQuery(term)) .boost(0.5f) // lower boost to reduce promotion of link-title-only matches @@ -166,7 +166,7 @@ public void searchByParametersWithoutDoubleQuote() { should.add(CQLFields.parameter_vocabs.getPropertyEqualToQuery(term)); should.add(CQLFields.organisation_vocabs.getPropertyEqualToQuery(term)); should.add(CQLFields.platform_vocabs.getPropertyEqualToQuery(term)); - should.add(CQLFields.id.getPropertyEqualToQuery(term)); + should.add(CQLFields.uuid.getPropertyEqualToQuery(term)); should.add(BoolQuery.of(b -> b .should(CQLFields.links_title_contains.getPropertyEqualToQuery(term)) .boost(0.5f) // lower boost to reduce promotion of link-title-only matches From 9ab558ccce1891b9567d73aae6f7e73125cb1283 Mon Sep 17 00:00:00 2001 From: rng Date: Wed, 6 May 2026 08:38:12 +1000 Subject: [PATCH 2/2] Fix test case --- .../java/au/org/aodn/ogcapi/server/common/RestApiTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/src/test/java/au/org/aodn/ogcapi/server/common/RestApiTest.java b/server/src/test/java/au/org/aodn/ogcapi/server/common/RestApiTest.java index 9e891140..e4aaf845 100644 --- a/server/src/test/java/au/org/aodn/ogcapi/server/common/RestApiTest.java +++ b/server/src/test/java/au/org/aodn/ogcapi/server/common/RestApiTest.java @@ -297,14 +297,14 @@ public void verifyPropertiesParameter() throws IOException { "516811d7-cd1e-207a-e0440003ba8c79dd.json" ); - ResponseEntity collections = testRestTemplate.getForEntity(getBasePath() + "/collections?datetime=../2007-06-05T14:00:00Z&properties=id,title", Collections.class); + ResponseEntity collections = testRestTemplate.getForEntity(getBasePath() + "/collections?datetime=../2007-06-05T14:00:00Z&properties=uuid,title", Collections.class); assertEquals(1, Objects.requireNonNull(collections.getBody()).getCollections().size(), "hit 1, only one record"); assertNotNull(collections.getBody().getCollections().get(0).getId()); assertNotNull(collections.getBody().getCollections().get(0).getTitle()); assertNull(collections.getBody().getCollections().get(0).getDescription()); - collections = testRestTemplate.getForEntity(getBasePath() + "/collections?datetime=../2007-06-05T14:00:00Z&properties=id,title,description", Collections.class); + collections = testRestTemplate.getForEntity(getBasePath() + "/collections?datetime=../2007-06-05T14:00:00Z&properties=uuid,title,description", Collections.class); assertNotNull(Objects.requireNonNull(collections.getBody()).getCollections().get(0).getDescription()); } /**