From 0b5929db126d8c77ebb6de69de3a25a8e9ce34d4 Mon Sep 17 00:00:00 2001 From: Michael Folz Date: Mon, 25 Nov 2024 11:27:12 +0100 Subject: [PATCH] #403 - Update spring boot to 3.4.0 - adapt to changes in elastic search client --- .../terminology/es/TerminologyEsService.java | 18 +++++++----------- .../es/CodeableConceptServiceTest.java | 2 +- .../es/TerminologyEsServiceTest.java | 2 +- 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/src/main/java/de/numcodex/feasibility_gui_backend/terminology/es/TerminologyEsService.java b/src/main/java/de/numcodex/feasibility_gui_backend/terminology/es/TerminologyEsService.java index 6c54ee55..ee346a7e 100644 --- a/src/main/java/de/numcodex/feasibility_gui_backend/terminology/es/TerminologyEsService.java +++ b/src/main/java/de/numcodex/feasibility_gui_backend/terminology/es/TerminologyEsService.java @@ -1,12 +1,10 @@ package de.numcodex.feasibility_gui_backend.terminology.es; import co.elastic.clients.elasticsearch._types.FieldValue; -import co.elastic.clients.elasticsearch._types.InlineScript; import co.elastic.clients.elasticsearch._types.Script; import co.elastic.clients.elasticsearch._types.aggregations.Aggregation; import co.elastic.clients.elasticsearch._types.aggregations.StringTermsBucket; import co.elastic.clients.elasticsearch._types.query_dsl.*; -import co.elastic.clients.json.JsonData; import de.numcodex.feasibility_gui_backend.terminology.api.EsSearchResult; import de.numcodex.feasibility_gui_backend.terminology.api.EsSearchResultEntry; import de.numcodex.feasibility_gui_backend.terminology.es.model.*; @@ -121,10 +119,12 @@ private SearchHits findByNameOrTermcode(String keyword List filterTerms = new ArrayList<>(); if (availability) { - var availabilityFilter = new RangeQuery.Builder() - .field("availability") - .gt(JsonData.of("0")) - .build(); + var availabilityFilter = RangeQuery.of(r -> r + .number(n -> n + .field("availability") + .gt(0.0) + ) + ); filterTerms.add(availabilityFilter._toQuery()); } @@ -164,12 +164,8 @@ private SearchHits findByNameOrTermcode(String keyword .withPageable(pageRequest) .build(); - var inlineScript = new InlineScript.Builder() - .source("doc['availability'].value == 0 ? _score : _score + 100") - .build(); - var availabilityScoreScript = new Script.Builder() - .inline(inlineScript) + .source("doc['availability'].value == 0 ? _score : _score + 100") .build(); var function = FunctionScoreBuilders.scriptScore() diff --git a/src/test/java/de/numcodex/feasibility_gui_backend/terminology/es/CodeableConceptServiceTest.java b/src/test/java/de/numcodex/feasibility_gui_backend/terminology/es/CodeableConceptServiceTest.java index 0a8b6bc0..5daa7d1b 100644 --- a/src/test/java/de/numcodex/feasibility_gui_backend/terminology/es/CodeableConceptServiceTest.java +++ b/src/test/java/de/numcodex/feasibility_gui_backend/terminology/es/CodeableConceptServiceTest.java @@ -143,7 +143,7 @@ private SearchHits createDummySearchHitsPage(int totalH ) ); } - return new SearchHitsImpl<>(totalHits, TotalHitsRelation.OFF, 10.0F, null, null, searchHitsList, null, null, null); + return new SearchHitsImpl<>(totalHits, TotalHitsRelation.OFF, 10.0F, null, null, null, searchHitsList, null, null, null); } private CodeableConceptDocument createDummyCodeableConceptDocument(String id) { diff --git a/src/test/java/de/numcodex/feasibility_gui_backend/terminology/es/TerminologyEsServiceTest.java b/src/test/java/de/numcodex/feasibility_gui_backend/terminology/es/TerminologyEsServiceTest.java index b71ed0ec..c8f3e12f 100644 --- a/src/test/java/de/numcodex/feasibility_gui_backend/terminology/es/TerminologyEsServiceTest.java +++ b/src/test/java/de/numcodex/feasibility_gui_backend/terminology/es/TerminologyEsServiceTest.java @@ -303,6 +303,6 @@ private SearchHits createDummySearchHitsPage(int total ) ); } - return new SearchHitsImpl<>(totalHits, TotalHitsRelation.OFF, 10.0F, null, null, searchHitsList, null, null, null); + return new SearchHitsImpl<>(totalHits, TotalHitsRelation.OFF, 10.0F, null, null, null, searchHitsList, null, null, null); } }