Skip to content

Commit 49d5091

Browse files
authored
Merge pull request #476 from weaviate/v6-drop-flaky-test
2 parents 3994900 + f5df7a3 commit 49d5091

2 files changed

Lines changed: 20 additions & 32 deletions

File tree

src/it/java/io/weaviate/integration/SearchITest.java

Lines changed: 3 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -269,9 +269,9 @@ public void testFetchObjectsWithSort() throws Exception {
269269

270270
var numbers = client.collections.use(nsNumbers);
271271

272-
var one = numbers.data.insert(Map.of("value", 1L));
273-
var two = numbers.data.insert(Map.of("value", 2L));
274-
var three = numbers.data.insert(Map.of("value", 3L));
272+
numbers.data.insert(Map.of("value", 1L));
273+
numbers.data.insert(Map.of("value", 2L));
274+
numbers.data.insert(Map.of("value", 3L));
275275

276276
// Act: sort ascending
277277
var asc = numbers.query.fetchObjects(
@@ -294,35 +294,6 @@ public void testFetchObjectsWithSort() throws Exception {
294294
.extracting(WeaviateObject::properties)
295295
.extracting(object -> object.get("value"))
296296
.containsExactly(3L, 2L, 1L);
297-
298-
// Act: sort by creation time asc
299-
var created = numbers.query.fetchObjects(
300-
q -> q.sort(SortBy.creationTime()));
301-
302-
Assertions.assertThat(created.objects())
303-
.as("create time asc")
304-
.hasSize(3)
305-
.extracting(WeaviateObject::uuid)
306-
.containsExactly(one.uuid(), two.uuid(), three.uuid());
307-
308-
// Act: sort by updated time desc
309-
numbers.data.update(one.uuid(), upd -> upd.properties(Map.of("value", -1L)));
310-
Thread.sleep(10);
311-
numbers.data.update(two.uuid(), upd -> upd.properties(Map.of("value", -2L)));
312-
Thread.sleep(10);
313-
numbers.data.update(three.uuid(), upd -> upd.properties(Map.of("value", -3L)));
314-
315-
var updated = numbers.query.fetchObjects(
316-
q -> q.sort(
317-
// Both sort operators imply ordering 3-2-1
318-
SortBy.lastUpdateTime().desc(),
319-
SortBy.property("value").asc()));
320-
321-
Assertions.assertThat(updated.objects())
322-
.as("last update time desc + value asc")
323-
.hasSize(3)
324-
.extracting(WeaviateObject::uuid)
325-
.containsExactly(three.uuid(), two.uuid(), one.uuid());
326297
}
327298

328299
@Test

src/main/java/io/weaviate/client6/v1/api/collections/query/SortBy.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,23 @@ public static SortBy property(String property) {
1212
return new SortBy(List.of(property), true);
1313
}
1414

15+
/**
16+
* Sort by object's UUID. Ascending order by default.
17+
*
18+
* <p>
19+
* Sorting by UUID may be useful if objects are assigned
20+
* custom UUIDv7 at ingestion, as those are "time-ordered".
21+
*
22+
* <p>
23+
* It may be less useful for the auto-generated UUIDs,
24+
* which will produce an essentialy random, albeit stable, order.
25+
*
26+
* @see #desc() to sort in descending order.
27+
*/
28+
public static SortBy uuid() {
29+
return property(ById.ID_PROPERTY);
30+
}
31+
1532
/**
1633
* Sort by object creation time. Ascending order by default.
1734
*

0 commit comments

Comments
 (0)