Skip to content
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

Changes related to the next Meilisearch release (v0.29.0) #434

Merged
merged 10 commits into from
Feb 13, 2023
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ jobs:
cache: gradle
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Meilisearch (v0.28.1 version) setup with Docker
run: docker run -d -p 7700:7700 getmeili/meilisearch:v0.28.1 meilisearch --no-analytics --master-key='masterKey'
- name: Meilisearch (v0.29.3 version) setup with Docker
run: docker run -d -p 7700:7700 getmeili/meilisearch:v0.29.3 meilisearch --no-analytics --master-key='masterKey'
- name: Build and run unit and integration tests
run: ./gradlew build integrationTest
- name: Archive test report
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ Client client = new Client(config);

## 🤖 Compatibility with Meilisearch

This package only guarantees compatibility with the [version v0.28.0 of Meilisearch](https://github.com/meilisearch/meilisearch/releases/tag/v0.28.0).
This package only guarantees compatibility with the [version v0.29.0 of Meilisearch](https://github.com/meilisearch/meilisearch/releases/tag/v0.29.0).

## 💡 Learn more

Expand Down
10 changes: 10 additions & 0 deletions src/main/java/com/meilisearch/sdk/SearchRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public class SearchRequest {
private String cropMarker;
private String highlightPreTag;
private String highlightPostTag;
private String matchingStrategy;
alallema marked this conversation as resolved.
Show resolved Hide resolved
private String[] attributesToHighlight;
private String[] filter;
private String[][] filterArray;
Expand Down Expand Up @@ -132,6 +133,7 @@ public SearchRequest(
null,
null,
null,
null,
attributesToHighlight,
filter,
null,
Expand Down Expand Up @@ -184,6 +186,7 @@ public SearchRequest(
cropMarker,
highlightPreTag,
highlightPostTag,
null,
attributesToHighlight,
filter,
null,
Expand Down Expand Up @@ -230,6 +233,7 @@ public SearchRequest(
null,
null,
null,
null,
attributesToHighlight,
null,
filterArray,
Expand All @@ -250,6 +254,7 @@ public SearchRequest(
* @param cropMarker String to customize default crop marker, default value: …
* @param highlightPreTag String to customize highlight tag before every highlighted query terms
* @param highlightPostTag String to customize highlight tag after every highlighted query terms
* @param matchingStrategy String to defines the strategy used to match query terms in documents
* @param attributesToHighlight Attributes whose values will contain highlighted matching terms
* @param filterArray String array that can take multiple nested filters
* @param showMatchesPosition Defines whether an object that contains information about the
Expand All @@ -267,6 +272,7 @@ public SearchRequest(
String cropMarker,
String highlightPreTag,
String highlightPostTag,
String matchingStrategy,
alallema marked this conversation as resolved.
Show resolved Hide resolved
String[] attributesToHighlight,
String[][] filterArray,
boolean showMatchesPosition,
Expand All @@ -282,6 +288,7 @@ public SearchRequest(
cropMarker,
highlightPreTag,
highlightPostTag,
matchingStrategy,
attributesToHighlight,
null,
filterArray,
Expand All @@ -300,6 +307,7 @@ private SearchRequest(
String cropMarker,
String highlightPreTag,
String highlightPostTag,
String matchingStrategy,
alallema marked this conversation as resolved.
Show resolved Hide resolved
String[] attributesToHighlight,
String[] filter,
String[][] filterArray,
Expand All @@ -315,6 +323,7 @@ private SearchRequest(
this.cropMarker = cropMarker;
this.highlightPreTag = highlightPreTag;
this.highlightPostTag = highlightPostTag;
this.matchingStrategy = matchingStrategy;
this.attributesToHighlight = attributesToHighlight;
this.setFilter(filter);
this.setFilterArray(filterArray);
Expand Down Expand Up @@ -352,6 +361,7 @@ public String toString() {
.put("cropMarker", this.cropMarker)
.put("highlightPreTag", this.highlightPreTag)
.put("highlightPostTag", this.highlightPostTag)
.put("matchingStrategy", this.matchingStrategy)
.put("showMatchesPosition", this.showMatchesPosition)
.put("facets", this.facets)
.put("sort", this.sort)
Expand Down
20 changes: 20 additions & 0 deletions src/test/java/com/meilisearch/integration/KeysTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,26 @@ public void testClientCreateKeyWithExpirationDate() throws Exception {
assertNotNull(key.getUpdatedAt());
}

/** Test Create an API Key with wildcarded action */
@Test
public void testClientCreateKeyWithWilcardedAction() throws Exception {
Key keyInfo = new Key();
keyInfo.setIndexes(new String[] {"*"});
keyInfo.setActions(new String[] {"documents.*"});
keyInfo.setExpiresAt(null);

Key key = client.createKey(keyInfo);

assertTrue(key instanceof Key);
alallema marked this conversation as resolved.
Show resolved Hide resolved
assertNotNull(key.getKey());
assertEquals("documents.*", key.getActions()[0]);
assertEquals("*", key.getIndexes()[0]);
assertNull(key.getDescription());
assertNull(key.getExpiresAt());
assertNotNull(key.getCreatedAt());
assertNotNull(key.getUpdatedAt());
}

/** Test Update an API Key */
@Test
public void testClientUpdateKey() throws Exception {
Expand Down
17 changes: 17 additions & 0 deletions src/test/java/com/meilisearch/integration/SearchTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,7 @@ public void testSearchMatches() throws Exception {

assertEquals(20, searchResult.getHits().size());
}

/** Test place holder search */
@Test
public void testPlaceHolder() throws Exception {
Expand Down Expand Up @@ -486,4 +487,20 @@ public void testPlaceHolderWithLimit() throws Exception {

assertEquals(10, searchResult.getHits().size());
}

/** Test search matchingStrategy */
@Test
public void testSearchMatchingStrategy() throws Exception {
String indexUid = "SearchMatchingStrategy";
Index index = client.index(indexUid);

TestData<Movie> testData = this.getTestData(MOVIES_INDEX, Movie.class);
TaskInfo task = index.addDocuments(testData.getRaw());

index.waitForTask(task.getTaskUid());
SearchRequest searchRequest = new SearchRequest("and").setMatchingStrategy("all");
SearchResult searchResult = index.search(searchRequest);

assertEquals(20, searchResult.getHits().size());
alallema marked this conversation as resolved.
Show resolved Hide resolved
}
}
3 changes: 2 additions & 1 deletion src/test/java/com/meilisearch/sdk/SearchRequestTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ void toStringEveryParametersWithArray() {
"123",
"abc",
"zyx",
"789",
new String[] {"highlight"},
new String[][] {
new String[] {"test='test'"}, new String[] {"test1='test1'"}
Expand All @@ -117,7 +118,7 @@ void toStringEveryParametersWithArray() {
assertEquals("sort", classToTest.getSort()[0]);
assertEquals(900, classToTest.getCropLength());
assertEquals(
"{\"attributesToRetrieve\":[\"bubble\"],\"offset\":200,\"cropMarker\":\"123\",\"sort\":[\"sort\"],\"highlightPreTag\":\"abc\",\"facets\":[\"facets\"],\"filter\":[[\"test='test'\"],[\"test1='test1'\"]],\"q\":\"This is a Test\",\"showMatchesPosition\":true,\"limit\":900,\"cropLength\":900,\"highlightPostTag\":\"zyx\",\"attributesToHighlight\":[\"highlight\"],\"attributesToCrop\":[\"crop\"]}",
"{\"attributesToRetrieve\":[\"bubble\"],\"offset\":200,\"cropMarker\":\"123\",\"sort\":[\"sort\"],\"highlightPreTag\":\"abc\",\"facets\":[\"facets\"],\"filter\":[[\"test='test'\"],[\"test1='test1'\"]],\"q\":\"This is a Test\",\"matchingStrategy\":\"789\",\"showMatchesPosition\":true,\"limit\":900,\"cropLength\":900,\"highlightPostTag\":\"zyx\",\"attributesToHighlight\":[\"highlight\"],\"attributesToCrop\":[\"crop\"]}",
classToTest.toString());
}
}