@@ -259,7 +259,7 @@ public void testFetchObjectsWithFilters() throws IOException {
259259 }
260260
261261 @ Test
262- public void testFetchObjectsWithSort () throws IOException {
262+ public void testFetchObjectsWithSort () throws Exception {
263263 var nsNumbers = ns ("Numbers" );
264264
265265 // Arrange
@@ -277,6 +277,7 @@ public void testFetchObjectsWithSort() throws IOException {
277277 q -> q .sort (SortBy .property ("value" )));
278278
279279 Assertions .assertThat (asc .objects ())
280+ .as ("value asc" )
280281 .hasSize (3 )
281282 .extracting (WeaviateObject ::properties )
282283 .extracting (object -> object .get ("value" ))
@@ -287,10 +288,40 @@ public void testFetchObjectsWithSort() throws IOException {
287288 q -> q .sort (SortBy .property ("value" ).desc ()));
288289
289290 Assertions .assertThat (desc .objects ())
291+ .as ("value desc" )
290292 .hasSize (3 )
291293 .extracting (WeaviateObject ::properties )
292294 .extracting (object -> object .get ("value" ))
293295 .containsExactly (3L , 2L , 1L );
296+
297+ // Act: sort by creation time asc
298+ var created = numbers .query .fetchObjects (
299+ q -> q .sort (SortBy .creationTime ()));
300+
301+ Assertions .assertThat (created .objects ())
302+ .as ("create time asc" )
303+ .hasSize (3 )
304+ .extracting (WeaviateObject ::uuid )
305+ .containsExactly (one .uuid (), two .uuid (), three .uuid ());
306+
307+ // Act: sort by updated time desc
308+ numbers .data .update (one .uuid (), upd -> upd .properties (Map .of ("value" , -1L )));
309+ Thread .sleep (10 );
310+ numbers .data .update (two .uuid (), upd -> upd .properties (Map .of ("value" , -2L )));
311+ Thread .sleep (10 );
312+ numbers .data .update (three .uuid (), upd -> upd .properties (Map .of ("value" , -3L )));
313+
314+ var updated = numbers .query .fetchObjects (
315+ q -> q .sort (
316+ // Both sort operators imply ordering 3-2-1
317+ SortBy .lastUpdateTime ().desc (),
318+ SortBy .property ("value" ).asc ()));
319+
320+ Assertions .assertThat (updated .objects ())
321+ .as ("last update time desc + value asc" )
322+ .hasSize (3 )
323+ .extracting (WeaviateObject ::uuid )
324+ .containsExactly (three .uuid (), two .uuid (), one .uuid ());
294325 }
295326
296327 @ Test
0 commit comments