Skip to content

Commit

Permalink
Merge pull request #434 from meilisearch/bump-meilisearch-v0.29.0
Browse files Browse the repository at this point in the history
Changes related to the next Meilisearch release (v0.29.0)
  • Loading branch information
alallema authored Feb 13, 2023
2 parents 61ae656 + ea8548e commit b5a8159
Show file tree
Hide file tree
Showing 8 changed files with 104 additions and 4 deletions.
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
2 changes: 1 addition & 1 deletion src/main/java/com/meilisearch/sdk/Search.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ String rawSearch(
*/
String rawSearch(String uid, SearchRequest sr) throws MeilisearchException {
String requestQuery = "/indexes/" + uid + "/search";
return httpClient.post(requestQuery, sr, String.class);
return httpClient.post(requestQuery, sr.toString(), String.class);
}

/**
Expand Down
16 changes: 16 additions & 0 deletions src/main/java/com/meilisearch/sdk/SearchRequest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.meilisearch.sdk;

import com.meilisearch.sdk.model.MatchingStrategy;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
Expand All @@ -19,6 +20,7 @@ public class SearchRequest {
private String cropMarker;
private String highlightPreTag;
private String highlightPostTag;
private MatchingStrategy matchingStrategy;
private String[] attributesToHighlight;
private String[] filter;
private String[][] filterArray;
Expand Down Expand Up @@ -132,6 +134,7 @@ public SearchRequest(
null,
null,
null,
null,
attributesToHighlight,
filter,
null,
Expand Down Expand Up @@ -184,6 +187,7 @@ public SearchRequest(
cropMarker,
highlightPreTag,
highlightPostTag,
null,
attributesToHighlight,
filter,
null,
Expand Down Expand Up @@ -230,6 +234,7 @@ public SearchRequest(
null,
null,
null,
null,
attributesToHighlight,
null,
filterArray,
Expand All @@ -250,6 +255,8 @@ 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 MatchingStrategy 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 +274,7 @@ public SearchRequest(
String cropMarker,
String highlightPreTag,
String highlightPostTag,
MatchingStrategy matchingStrategy,
String[] attributesToHighlight,
String[][] filterArray,
boolean showMatchesPosition,
Expand All @@ -282,6 +290,7 @@ public SearchRequest(
cropMarker,
highlightPreTag,
highlightPostTag,
matchingStrategy,
attributesToHighlight,
null,
filterArray,
Expand All @@ -300,6 +309,7 @@ private SearchRequest(
String cropMarker,
String highlightPreTag,
String highlightPostTag,
MatchingStrategy matchingStrategy,
String[] attributesToHighlight,
String[] filter,
String[][] filterArray,
Expand All @@ -315,6 +325,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 +363,11 @@ public String toString() {
.put("cropMarker", this.cropMarker)
.put("highlightPreTag", this.highlightPreTag)
.put("highlightPostTag", this.highlightPostTag)
.put(
"matchingStrategy",
this.matchingStrategy == null
? null
: this.matchingStrategy.toString())
.put("showMatchesPosition", this.showMatchesPosition)
.put("facets", this.facets)
.put("sort", this.sort)
Expand Down
17 changes: 17 additions & 0 deletions src/main/java/com/meilisearch/sdk/model/MatchingStrategy.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.meilisearch.sdk.model;

public enum MatchingStrategy {
ALL("all"),
LAST("last");

public final String matchingStrategy;

private MatchingStrategy(String matchingStrategy) {
this.matchingStrategy = matchingStrategy;
}

@Override
public String toString() {
return this.matchingStrategy;
}
}
19 changes: 19 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,25 @@ 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);

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
1 change: 1 addition & 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
47 changes: 47 additions & 0 deletions src/test/java/com/meilisearch/sdk/SearchRequestTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import static org.junit.jupiter.api.Assertions.assertEquals;

import com.meilisearch.sdk.model.MatchingStrategy;
import org.junit.jupiter.api.Test;

class SearchRequestTest {
Expand Down Expand Up @@ -92,6 +93,7 @@ void toStringEveryParametersWithArray() {
"123",
"abc",
"zyx",
MatchingStrategy.ALL,
new String[] {"highlight"},
new String[][] {
new String[] {"test='test'"}, new String[] {"test1='test1'"}
Expand All @@ -105,6 +107,51 @@ void toStringEveryParametersWithArray() {
assertEquals(900, classToTest.getLimit());
assertEquals("123", classToTest.getCropMarker());
assertEquals("abc", classToTest.getHighlightPreTag());
assertEquals(MatchingStrategy.ALL, classToTest.getMatchingStrategy());
assertEquals("zyx", classToTest.getHighlightPostTag());
assertEquals("bubble", classToTest.getAttributesToRetrieve()[0]);
assertEquals("highlight", classToTest.getAttributesToHighlight()[0]);
assertEquals("crop", classToTest.getAttributesToCrop()[0]);
assertEquals(null, classToTest.getFilter());
assertEquals(2, classToTest.getFilterArray().length);
assertEquals("test='test'", classToTest.getFilterArray()[0][0]);
assertEquals("test1='test1'", classToTest.getFilterArray()[1][0]);
assertEquals("facets", classToTest.getFacets()[0]);
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\",\"matchingStrategy\":\"all\",\"showMatchesPosition\":true,\"limit\":900,\"cropLength\":900,\"highlightPostTag\":\"zyx\",\"attributesToHighlight\":[\"highlight\"],\"attributesToCrop\":[\"crop\"]}",
classToTest.toString());
}

@Test
void toStringEveryParametersWithArrayMatchingStrategyNull() {
SearchRequest classToTest =
new SearchRequest(
"This is a Test",
200,
900,
new String[] {"bubble"},
new String[] {"crop"},
900,
"123",
"abc",
"zyx",
null,
new String[] {"highlight"},
new String[][] {
new String[] {"test='test'"}, new String[] {"test1='test1'"}
},
true,
new String[] {"facets"},
new String[] {"sort"});

assertEquals("This is a Test", classToTest.getQ());
assertEquals(200, classToTest.getOffset());
assertEquals(900, classToTest.getLimit());
assertEquals("123", classToTest.getCropMarker());
assertEquals("abc", classToTest.getHighlightPreTag());
assertEquals(null, classToTest.getMatchingStrategy());
assertEquals("zyx", classToTest.getHighlightPostTag());
assertEquals("bubble", classToTest.getAttributesToRetrieve()[0]);
assertEquals("highlight", classToTest.getAttributesToHighlight()[0]);
Expand Down

0 comments on commit b5a8159

Please sign in to comment.