-
Notifications
You must be signed in to change notification settings - Fork 148
fix(python,java,node,rust): add missing vector search 1.1 args #5550
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -317,6 +317,111 @@ public void ft_search() { | |
| assertTrue(exception.getMessage().contains("Index not found")); | ||
| } | ||
|
|
||
| @SneakyThrows | ||
| @Test | ||
| public void ft_search_nocontent() { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So from what I gathered, this test is doing:
The additional vector syntax make this test feels complicated for me. Since the focus is to check nocontent was applied, could we just use a simple set and get test with nocontent and assert the response?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should keep this test as is. The issue with
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's simplify this test and keep it to the point. People will most likely copy test code around so a complicated test means more chance for errors. Also make sure to update the other languages as well. |
||
| String prefix = "{" + UUID.randomUUID() + "}:"; | ||
| String index = prefix + "index"; | ||
|
|
||
| assertEquals( | ||
| OK, | ||
| FT.create( | ||
| client, | ||
| index, | ||
| new FieldInfo[] { | ||
| new FieldInfo("vec", "VEC", VectorFieldFlat.builder(DistanceMetric.L2, 2).build()) | ||
| }, | ||
| FTCreateOptions.builder() | ||
| .dataType(DataType.HASH) | ||
| .prefixes(new String[] {prefix}) | ||
| .build()) | ||
| .get()); | ||
|
|
||
| String key1 = prefix + "0"; | ||
| String key2 = prefix + "1"; | ||
|
|
||
| assertEquals( | ||
| 1L, | ||
| client | ||
| .hset( | ||
| gs(key1), | ||
| createMap( | ||
| gs("vec"), | ||
| gs( | ||
| new byte[] { | ||
| (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, | ||
| (byte) 0 | ||
| }))) | ||
| .get()); | ||
| assertEquals( | ||
| 1L, | ||
| client | ||
| .hset( | ||
| gs(key2), | ||
| createMap( | ||
| gs("vec"), | ||
| gs( | ||
| new byte[] { | ||
| (byte) 0, | ||
| (byte) 0, | ||
| (byte) 0, | ||
| (byte) 0, | ||
| (byte) 0, | ||
| (byte) 0, | ||
| (byte) 0x80, | ||
| (byte) 0xBF | ||
| }))) | ||
| .get()); | ||
| Thread.sleep(DATA_PROCESSING_TIMEOUT); | ||
|
|
||
| FTSearchOptions options = | ||
| FTSearchOptions.builder() | ||
| .nocontent() | ||
| .params( | ||
| createMap( | ||
| gs("query_vec"), | ||
| gs( | ||
| new byte[] { | ||
| (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, | ||
| (byte) 0 | ||
| }))) | ||
| .build(); | ||
| String query = "*=>[KNN 2 @VEC $query_vec]"; | ||
| Object[] ftsearch = FT.search(client, index, query, options).get(); | ||
|
|
||
| assertArrayEquals( | ||
| new Object[] {2L, createMap(gs(key1), createMap(), gs(key2), createMap())}, ftsearch); | ||
| } | ||
|
|
||
| @SneakyThrows | ||
| @Test | ||
| public void ft_search_dialect() { | ||
edlng marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| String prefix = "{" + UUID.randomUUID() + "}:"; | ||
| String index = prefix + "index"; | ||
| String key = prefix + "doc"; | ||
|
|
||
| assertEquals( | ||
| OK, | ||
| FT.create( | ||
| client, | ||
| index, | ||
| new FieldInfo[] {new FieldInfo("title", new TextField())}, | ||
| FTCreateOptions.builder() | ||
| .dataType(DataType.HASH) | ||
| .prefixes(new String[] {prefix}) | ||
| .build()) | ||
| .get()); | ||
|
|
||
| assertEquals(1L, client.hset(gs(key), createMap(gs("title"), gs("hello world"))).get()); | ||
| Thread.sleep(DATA_PROCESSING_TIMEOUT); | ||
|
|
||
| // dialect 2 is accepted; assert the document is returned | ||
| Object[] result = | ||
| FT.search(client, index, "hello", FTSearchOptions.builder().dialect(2).build()).get(); | ||
| assertEquals(2, result.length); | ||
| assertEquals(1L, result[0]); | ||
| } | ||
|
|
||
| @SneakyThrows | ||
| @Test | ||
| public void ft_drop_and_ft_list() { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you check the formatting for this file? The spacing seems weird.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Talked with Kiro about it, but apparently it follows the Google Java Style convention. Running spotless checks also pass. I do agree formatting might be a bit weird but I think a lot of the existing Java files follow this convention so fixing it might be a project-wide task 😵💫