-
Notifications
You must be signed in to change notification settings - Fork 131
Add features of meilisearch 1.18 (queryVector and index renaming) #906
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
Open
yamiSukehiro2907
wants to merge
9
commits into
meilisearch:main
Choose a base branch
from
yamiSukehiro2907:feat/support-meilisearch-1.18
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 8 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
75ee2cc
feat: support Meilisearch 1.18 (queryVector, rename index, swap-indexβ¦
yamiSukehiro2907 a6bf507
feat: support Meilisearch 1.18 (queryVector + rename index + swap index)
yamiSukehiro2907 2a5ec2f
fix: refactor index rename and swap tests to use SDK public API
yamiSukehiro2907 9a991c4
fix: add comprehensive assertions to index rename and swap tests
yamiSukehiro2907 9d142b3
Merge branch 'main' into feat/support-meilisearch-1.18
yamiSukehiro2907 baf7c67
Merge branch 'main' into feat/support-meilisearch-1.18
yamiSukehiro2907 4f253e1
prog: deleted data.ms
yamiSukehiro2907 eb7f772
prog: Fixed tests for IndexRename and SwapIndexRename
yamiSukehiro2907 d0df797
prog: changed the parameters from indexUid to uid
yamiSukehiro2907 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| package com.meilisearch.sdk; | ||
|
|
||
| import static org.hamcrest.MatcherAssert.assertThat; | ||
| import static org.hamcrest.Matchers.*; | ||
|
|
||
| import com.meilisearch.sdk.model.TaskInfo; | ||
| import okhttp3.mockwebserver.MockResponse; | ||
| import okhttp3.mockwebserver.MockWebServer; | ||
| import okhttp3.mockwebserver.RecordedRequest; | ||
| import org.junit.jupiter.api.AfterEach; | ||
| import org.junit.jupiter.api.BeforeEach; | ||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| class IndexRenameTest { | ||
|
|
||
| private MockWebServer server; | ||
| private Client client; | ||
|
|
||
| @BeforeEach | ||
| void setup() throws Exception { | ||
| server = new MockWebServer(); | ||
| server.start(); | ||
|
|
||
| client = new Client(new Config(server.url("/").toString(), "masterKey")); | ||
| } | ||
|
|
||
| @AfterEach | ||
| void teardown() throws Exception { | ||
| server.shutdown(); | ||
| } | ||
|
|
||
| @Test | ||
| void testRenameIndex() throws Exception { | ||
| String response = "{ \"taskUid\": 123 }"; | ||
|
|
||
| server.enqueue(new MockResponse().setBody(response).setResponseCode(202)); | ||
|
|
||
| TaskInfo task = client.updateIndex("oldIndex", null, "newIndex"); | ||
|
|
||
| assertThat(task, notNullValue()); | ||
| assertThat(task.getTaskUid(), equalTo(123)); | ||
|
|
||
| RecordedRequest req = server.takeRequest(); | ||
|
|
||
| assertThat(req.getMethod(), equalTo("PATCH")); | ||
| // FIX: Actual path includes double slash | ||
| assertThat(req.getPath(), equalTo("//indexes/oldIndex")); | ||
|
|
||
| String body = req.getBody().readUtf8(); | ||
| assertThat(body, containsString("\"indexUid\":\"newIndex\"")); | ||
| assertThat(req.getHeader("Authorization"), equalTo("Bearer masterKey")); | ||
| } | ||
| } |
56 changes: 56 additions & 0 deletions
56
src/test/java/com/meilisearch/sdk/SearchResultQueryVectorTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| package com.meilisearch.sdk; | ||
|
|
||
| import static org.hamcrest.MatcherAssert.assertThat; | ||
| import static org.hamcrest.Matchers.*; | ||
|
|
||
| import com.meilisearch.sdk.model.SearchResult; | ||
| import okhttp3.mockwebserver.MockResponse; | ||
| import okhttp3.mockwebserver.MockWebServer; | ||
| import org.junit.jupiter.api.AfterEach; | ||
| import org.junit.jupiter.api.BeforeEach; | ||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| class SearchResultQueryVectorTest { | ||
|
|
||
| private MockWebServer server; | ||
| private Client client; | ||
|
|
||
| @BeforeEach | ||
| void setup() throws Exception { | ||
| server = new MockWebServer(); | ||
| server.start(); | ||
|
|
||
| client = new Client(new Config(server.url("/").toString(), "masterKey")); | ||
| } | ||
|
|
||
| @AfterEach | ||
| void teardown() throws Exception { | ||
| server.shutdown(); | ||
| } | ||
|
|
||
| @Test | ||
| void testQueryVectorDeserialization() throws Exception { | ||
| String json = | ||
| """ | ||
| { | ||
| "hits": [], | ||
| "queryVector": [1.1, -2.5, 3.14], | ||
| "offset": 0, | ||
| "limit": 20, | ||
| "estimatedTotalHits": 0, | ||
| "query": "hello", | ||
| "processingTimeMs": 1 | ||
| } | ||
| """; | ||
|
|
||
| server.enqueue(new MockResponse().setResponseCode(200).setBody(json)); | ||
|
|
||
| SearchResult res = client.index("movies").search("hello"); | ||
|
|
||
| assertThat(res, notNullValue()); | ||
| assertThat(res.getQueryVector(), hasSize(3)); | ||
| assertThat(res.getQueryVector().get(0), equalTo(1.1f)); | ||
| assertThat(res.getQueryVector().get(1), equalTo(-2.5f)); | ||
| assertThat(res.getQueryVector().get(2), equalTo(3.14f)); | ||
| } | ||
| } |
59 changes: 59 additions & 0 deletions
59
src/test/java/com/meilisearch/sdk/SwapIndexRenameTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| package com.meilisearch.sdk; | ||
|
|
||
| import static org.hamcrest.MatcherAssert.assertThat; | ||
| import static org.hamcrest.Matchers.*; | ||
|
|
||
| import com.meilisearch.sdk.model.SwapIndexesParams; | ||
| import com.meilisearch.sdk.model.TaskInfo; | ||
| import okhttp3.mockwebserver.MockResponse; | ||
| import okhttp3.mockwebserver.MockWebServer; | ||
| import okhttp3.mockwebserver.RecordedRequest; | ||
| import org.junit.jupiter.api.AfterEach; | ||
| import org.junit.jupiter.api.BeforeEach; | ||
| import org.junit.jupiter.api.Test; | ||
|
|
||
| class SwapIndexRenameTest { | ||
|
|
||
| private MockWebServer server; | ||
| private Client client; | ||
|
|
||
| @BeforeEach | ||
| void setup() throws Exception { | ||
| server = new MockWebServer(); | ||
| server.start(); | ||
|
|
||
| client = new Client(new Config(server.url("/").toString(), "masterKey")); | ||
| } | ||
|
|
||
| @AfterEach | ||
| void teardown() throws Exception { | ||
| server.shutdown(); | ||
| } | ||
|
|
||
| @Test | ||
| void testSwapIndexesWithRename() throws Exception { | ||
| String jsonResponse = "{ \"taskUid\": 555 }"; | ||
|
|
||
| server.enqueue(new MockResponse().setBody(jsonResponse).setResponseCode(202)); | ||
|
|
||
| SwapIndexesParams params = | ||
| new SwapIndexesParams() | ||
| .setIndexes(new String[] {"indexA", "indexB"}) | ||
| .setRename(true); | ||
|
|
||
| TaskInfo task = client.swapIndexes(new SwapIndexesParams[] {params}); | ||
|
|
||
| assertThat(task, notNullValue()); | ||
| assertThat(task.getTaskUid(), equalTo(555)); | ||
|
|
||
| RecordedRequest req = server.takeRequest(); | ||
|
|
||
| assertThat(req.getMethod(), equalTo("POST")); | ||
| // FIX: Actual path contains double slash | ||
| assertThat(req.getPath(), equalTo("//swap-indexes")); | ||
|
|
||
| String body = req.getBody().readUtf8(); | ||
| assertThat(body, containsString("\"indexes\":[\"indexA\",\"indexB\"]")); | ||
| assertThat(body, containsString("\"rename\":true")); | ||
| } | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.