Skip to content

Commit

Permalink
#403 - Update spring boot to 3.4.0
Browse files Browse the repository at this point in the history
- adapt to changes in elastic search client
  • Loading branch information
michael-82 committed Nov 25, 2024
1 parent f4d7aa4 commit 0b5929d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -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.*;
Expand Down Expand Up @@ -121,10 +119,12 @@ private SearchHits<OntologyListItemDocument> findByNameOrTermcode(String keyword
List<Query> 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());
}

Expand Down Expand Up @@ -164,12 +164,8 @@ private SearchHits<OntologyListItemDocument> 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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ private SearchHits<CodeableConceptDocument> 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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,6 @@ private SearchHits<OntologyListItemDocument> 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);
}
}

0 comments on commit 0b5929d

Please sign in to comment.