From e7601a8e51b39d30203e615e9e7f1ff4f8f011be Mon Sep 17 00:00:00 2001 From: Rustam_Lotsmanenko <rustam_lotsmanenko@epam.com> Date: Wed, 19 Mar 2025 15:00:51 +0200 Subject: [PATCH] enforce correct ordering for tests that rely on ordering --- .../java/org/opengroup/osdu/util/ElasticUtils.java | 10 +++++++++- .../java/org/opengroup/osdu/util/ElasticUtils.java | 10 +++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/indexer-acceptance-test/src/test/java/org/opengroup/osdu/util/ElasticUtils.java b/indexer-acceptance-test/src/test/java/org/opengroup/osdu/util/ElasticUtils.java index 0f767a838..43e8f65bf 100644 --- a/indexer-acceptance-test/src/test/java/org/opengroup/osdu/util/ElasticUtils.java +++ b/indexer-acceptance-test/src/test/java/org/opengroup/osdu/util/ElasticUtils.java @@ -19,8 +19,10 @@ package org.opengroup.osdu.util; import co.elastic.clients.elasticsearch.ElasticsearchClient; import co.elastic.clients.elasticsearch._types.ElasticsearchException; +import co.elastic.clients.elasticsearch._types.FieldSort; import co.elastic.clients.elasticsearch._types.FieldValue; import co.elastic.clients.elasticsearch._types.GeoShapeRelation; +import co.elastic.clients.elasticsearch._types.SortOptions; import co.elastic.clients.elasticsearch._types.Time; import co.elastic.clients.elasticsearch._types.mapping.TypeMapping; import co.elastic.clients.elasticsearch._types.query_dsl.*; @@ -512,7 +514,13 @@ public class ElasticUtils { try { ElasticsearchClient client = this.getOrCreateClient(username, password, host); - SearchRequest request = SearchRequest.of(builder -> builder.index(index)); + SortOptions idSort = SortOptions.of( + sortBuilder -> sortBuilder.field( + FieldSort.of(fieldSortBuilder -> fieldSortBuilder.field("id")) + ) + ); + + SearchRequest request = SearchRequest.of(builder -> builder.index(index).sort(idSort)); SearchResponse<RecordData> searchResponse = client.search(request, RecordData.class); HitsMetadata<RecordData> hits = searchResponse.hits(); diff --git a/testing/indexer-test-core/src/main/java/org/opengroup/osdu/util/ElasticUtils.java b/testing/indexer-test-core/src/main/java/org/opengroup/osdu/util/ElasticUtils.java index eeae9569c..b2dd5868a 100644 --- a/testing/indexer-test-core/src/main/java/org/opengroup/osdu/util/ElasticUtils.java +++ b/testing/indexer-test-core/src/main/java/org/opengroup/osdu/util/ElasticUtils.java @@ -21,8 +21,10 @@ import static org.opengroup.osdu.common.RecordSteps.X_COLLABORATION; import co.elastic.clients.elasticsearch.ElasticsearchClient; import co.elastic.clients.elasticsearch._types.ElasticsearchException; +import co.elastic.clients.elasticsearch._types.FieldSort; import co.elastic.clients.elasticsearch._types.FieldValue; import co.elastic.clients.elasticsearch._types.GeoShapeRelation; +import co.elastic.clients.elasticsearch._types.SortOptions; import co.elastic.clients.elasticsearch._types.Time; import co.elastic.clients.elasticsearch._types.mapping.TypeMapping; import co.elastic.clients.elasticsearch._types.query_dsl.BoolQuery; @@ -542,7 +544,13 @@ public class ElasticUtils { try { ElasticsearchClient client = this.getOrCreateClient(username, password, host); - SearchRequest request = SearchRequest.of(builder -> builder.index(index)); + SortOptions idSort = SortOptions.of( + sortBuilder -> sortBuilder.field( + FieldSort.of(fieldSortBuilder -> fieldSortBuilder.field("id")) + ) + ); + + SearchRequest request = SearchRequest.of(builder -> builder.index(index).sort(idSort)); SearchResponse<RecordData> searchResponse = client.search(request, RecordData.class); HitsMetadata<RecordData> hits = searchResponse.hits(); -- GitLab