Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
Yury-Fridlyand committed Oct 8, 2024
1 parent 641c885 commit 9767901
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions java/integTest/src/test/java/glide/modules/VectorSearchTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,12 @@ public void ft_create() {
.get());

// create an index with multiple prefixes
var name = UUID.randomUUID().toString();
var index = UUID.randomUUID().toString();
assertEquals(
OK,
client
.ftcreate(
name,
index,
FTCreateOptions.builder()
.indexType(IndexType.HASH)
.prefixes(new String[] {"author:details:", "book:details:"})
Expand All @@ -160,7 +160,7 @@ public void ft_create() {
() ->
client
.ftcreate(
name,
index,
FTCreateOptions.empty(),
new FieldInfo[] {
new FieldInfo("title", new TextField()),
Expand Down Expand Up @@ -252,7 +252,7 @@ public void ft_search() {
(byte) 0xBF
})))
.get());

Thread.sleep(500);
var ftsearch =
client
.ftsearch(
Expand Down Expand Up @@ -307,6 +307,8 @@ public void ft_search() {
.get());
assertInstanceOf(RequestException.class, exception.getCause());
assertTrue(exception.getMessage().contains("Index not found"));

client.ftdrop(index).get();
}

@SneakyThrows
Expand Down Expand Up @@ -388,18 +390,17 @@ public void ft_info() {
new FieldInfo[] {
new FieldInfo(
"$.vec", "VEC", VectorFieldHnsw.builder(DistanceMetric.COSINE, 42).build()),
new FieldInfo("name", new TextField()),
new FieldInfo("$.name", new TextField()),
})
.get());

var response = client.ftinfo(index).get();
assertEquals(index, response.get("index_name"));
assertEquals("AVAILABLE", response.get("index_status"));
assertEquals("JSON", response.get("key_type"));
assertArrayEquals(new String[] {"123"}, (Object[]) response.get("key_prefixes"));
var fields = (Object[]) response.get("fields");
assertEquals(2, fields.length);
var f1 = (Map<String, Object>) fields[0];
var f1 = (Map<String, Object>) fields[1];
assertEquals("$.vec", f1.get("identifier"));
assertEquals("VECTOR", f1.get("type"));
assertEquals("VEC", f1.get("field_name"));
Expand All @@ -408,7 +409,13 @@ public void ft_info() {
assertEquals(42L, f1params.get("dimension"));

assertEquals(
Map.of("identifier", "name", "type", "TEXT", "field_name", "name", "option", ""),
fields[1]);
Map.of("identifier", "$.name", "type", "TEXT", "field_name", "$.name", "option", ""),
fields[0]);

client.ftdrop(index).get();

var exception = assertThrows(ExecutionException.class, () -> client.ftinfo(index).get());
assertInstanceOf(RequestException.class, exception.getCause());
assertTrue(exception.getMessage().contains("Index not found"));
}
}

0 comments on commit 9767901

Please sign in to comment.