Skip to content

Commit

Permalink
Keep original sorts order (opensearch-project#81)
Browse files Browse the repository at this point in the history
Signed-off-by: David Zane <[email protected]>
  • Loading branch information
dzane17 authored Aug 29, 2024
1 parent 99ccbca commit 3c561e0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,6 @@ static String buildSortShape(List<SortBuilder<?>> sortBuilderList, Boolean showF
shapeStrings.add(stringBuilder.toString());
}

Collections.sort(shapeStrings);
for (String line : shapeStrings) {
sortShape.append(line).append("\n");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ public void testComplexSearch() {
+ " derivative\n"
+ " max_bucket\n"
+ "sort:\n"
+ " asc [album]\n"
+ " asc [price]\n"
+ " desc [color]\n"
+ " desc [vendor]\n";
+ " desc [vendor]\n"
+ " asc [price]\n"
+ " asc [album]\n";
assertEquals(expectedShowFieldsTrue, shapeShowFieldsTrue);

String shapeShowFieldsFalse = QueryShapeGenerator.buildShape(sourceBuilder, false);
Expand Down Expand Up @@ -82,10 +82,10 @@ public void testComplexSearch() {
+ " derivative\n"
+ " max_bucket\n"
+ "sort:\n"
+ " asc\n"
+ " asc\n"
+ " desc\n"
+ " desc\n";
+ " desc\n"
+ " asc\n"
+ " asc\n";
assertEquals(expectedShowFieldsFalse, shapeShowFieldsFalse);
}

Expand Down Expand Up @@ -167,11 +167,11 @@ public void testSortShape() {
SearchSourceBuilder sourceBuilder = SearchSourceBuilderUtils.createSortSearchSourceBuilder();

String shapeShowFieldsTrue = QueryShapeGenerator.buildShape(sourceBuilder, true);
String expectedShowFieldsTrue = "sort:\n" + " asc [album]\n" + " asc [price]\n" + " desc [color]\n" + " desc [vendor]\n";
String expectedShowFieldsTrue = "sort:\n" + " desc [color]\n" + " desc [vendor]\n" + " asc [price]\n" + " asc [album]\n";
assertEquals(expectedShowFieldsTrue, shapeShowFieldsTrue);

String shapeShowFieldsFalse = QueryShapeGenerator.buildShape(sourceBuilder, false);
String expectedShowFieldsFalse = "sort:\n" + " asc\n" + " asc\n" + " desc\n" + " desc\n";
String expectedShowFieldsFalse = "sort:\n" + " desc\n" + " desc\n" + " asc\n" + " asc\n";
assertEquals(expectedShowFieldsFalse, shapeShowFieldsFalse);
}

Expand Down

0 comments on commit 3c561e0

Please sign in to comment.