Skip to content

Commit

Permalink
Merge #157
Browse files Browse the repository at this point in the history
157: Changes related to the next MeiliSearch release (v0.21.0) r=curquiza a=meili-bot

Related to this issue: meilisearch/integration-guides#117

This PR:
- gathers the changes related to the next MeiliSearch release (v0.21.0) so that this package is ready when the official release is out.
- should pass the tests against the [latest pre-release of MeiliSearch](https://github.com/meilisearch/MeiliSearch/releases). Until there is an RC version, the tests should be valid against the [alpha versions of transplant](https://github.com/meilisearch/transplant/releases).
- might eventually contain test failures until the MeiliSearch v0.21.0 is out.

⚠️ This PR should NOT be merged until the next release of MeiliSearch (v0.21.0) is out.

_This PR is auto-generated for the [pre-release week](https://github.com/meilisearch/integration-guides/blob/master/guides/pre-release-week.md) purpose. Exceptionally for this release, the pre-release time will be more than just one week._

Done:
- Update README #176
- Rename `buildDate` into `commitDate` #177 
- Rename `attributes_for_faceting` into `filterable_attributes` #178
- Rename `FieldsDsitribution` into `FieldDistribution` #179
- Add Fields in Dump #180
- Rename Filters into Filter #181 
- Fix part of the tests #182 
- Add missing tests according to new features #186 


Co-authored-by: meili-bot <74670311+meili-bot@users.noreply.github.com>
Co-authored-by: alallema <amelie@meilisearch.com>
Co-authored-by: Amélie <alallema@users.noreply.github.com>
  • Loading branch information
4 people authored Aug 24, 2021
2 parents ae7a203 + e187221 commit a8987c9
Show file tree
Hide file tree
Showing 18 changed files with 154 additions and 86 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: MeiliSearch (latest version) setup with Docker
run: docker run -d -p 7700:7700 getmeili/meilisearch:latest ./meilisearch --no-analytics=true --no-sentry=true --master-key='masterKey'
run: docker run -d -p 7700:7700 getmeili/meilisearch:latest ./meilisearch --no-analytics=true --master-key='masterKey'
- name: Build and run unit and integration tests
run: ./gradlew build integrationTest

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class TestMeiliSearch {
}
```

With the `updateId`, you can check the status (`enqueued`, `processed` or `failed`) of your documents addition using the [update endpoint](https://docs.meilisearch.com/reference/api/updates.html#get-an-update-status).
With the `updateId`, you can check the status (`enqueued`, `processing`, `processed` or `failed`) of your documents addition using the [update endpoint](https://docs.meilisearch.com/reference/api/updates.html#get-an-update-status).

#### Basic Search <!-- omit in toc -->

Expand Down Expand Up @@ -127,7 +127,7 @@ import com.meilisearch.sdk.SearchRequest;

// ...

String results = index.search(
SearchResult results = index.search(
new SearchRequest("in")
.setMatches(true)
.setAttributesToHighlight(new String[]{"title"})
Expand Down Expand Up @@ -156,7 +156,7 @@ System.out.println(results.getHits());

## 🤖 Compatibility with MeiliSearch

This package only guarantees the compatibility with the [version v0.20.0 of MeiliSearch](https://github.com/meilisearch/MeiliSearch/releases/tag/v0.20.0).
This package only guarantees the compatibility with the [version v0.21.0 of MeiliSearch](https://github.com/meilisearch/MeiliSearch/releases/tag/v0.21.0).

## 💡 Learn More

Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/meilisearch/sdk/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ public Index getOrCreateIndex(String uid) throws Exception {
* Triggers the creation of a MeiliSearch dump. Refer
* https://docs.meilisearch.com/reference/api/dump.html#create-a-dump
*
* @return Dump instance
* @throws Exception if an error occurs
*/
public Dump createDump() throws Exception {
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/com/meilisearch/sdk/Dump.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package com.meilisearch.sdk;

import lombok.Getter;
import lombok.ToString;

/** MeiliSearch dump */
public class Dump {
@Getter private String status;
@Getter private String uid;
@Getter @ToString.Exclude private String startedAt;
@Getter @ToString.Exclude private String finishedAt;
}
12 changes: 6 additions & 6 deletions src/main/java/com/meilisearch/sdk/Search.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ String rawSearch(String uid, String q) throws Exception {
* @param attributesToCrop Attributes whose values have been cropped
* @param cropLength Length used to crop field values
* @param attributesToHighlight Attributes whose values will contain highlighted matching terms
* @param filters Filter queries by an attribute value
* @param filter Filter queries by an attribute value
* @param matches Defines whether an object that contains information about the matches should
* be returned or not
* @param facetsDistribution Facets for which to retrieve the matching count
Expand All @@ -57,7 +57,7 @@ String rawSearch(
String[] attributesToCrop,
int cropLength,
String[] attributesToHighlight,
String filters,
String filter,
boolean matches,
String[] facetsDistribution)
throws Exception {
Expand All @@ -71,7 +71,7 @@ String rawSearch(
attributesToCrop,
cropLength,
attributesToHighlight,
filters,
filter,
matches,
facetsDistribution);
return meilisearchHttpRequest.post(requestQuery, sr.getQuery());
Expand Down Expand Up @@ -112,7 +112,7 @@ SearchResult search(String uid, String q) throws Exception {
* @param attributesToCrop Attributes whose values have been cropped
* @param cropLength Length used to crop field values
* @param attributesToHighlight Attributes whose values will contain highlighted matching terms
* @param filters Filter queries by an attribute value
* @param filter Filter queries by an attribute value
* @param matches Defines whether an object that contains information about the matches should
* be returned or not
* @param facetsDistribution Facets for which to retrieve the matching count
Expand All @@ -128,7 +128,7 @@ SearchResult search(
String[] attributesToCrop,
int cropLength,
String[] attributesToHighlight,
String filters,
String filter,
boolean matches,
String[] facetsDistribution)
throws Exception {
Expand All @@ -142,7 +142,7 @@ SearchResult search(
attributesToCrop,
cropLength,
attributesToHighlight,
filters,
filter,
matches,
facetsDistribution),
SearchResult.class);
Expand Down
36 changes: 18 additions & 18 deletions src/main/java/com/meilisearch/sdk/SearchRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class SearchRequest {
private String[] attributesToCrop;
private int cropLength;
private String[] attributesToHighlight;
private String filters;
private String filter;
private boolean matches;
private String[] facetsDistribution;

Expand All @@ -21,7 +21,7 @@ public SearchRequest() {}
/**
* Constructor for SearchRequest for building search queries with the default values: offset: 0,
* limit: 20, attributesToRetrieve: ["*"], attributesToCrop: null, cropLength: 200,
* attributesToHighlight: null, filters: null, matches: false, facetsDistribution: null
* attributesToHighlight: null, filter: null, matches: false, facetsDistribution: null
*
* @param q Query String
*/
Expand All @@ -32,7 +32,7 @@ public SearchRequest(String q) {
/**
* Constructor for SearchRequest for building search queries with the default values: limit: 20,
* attributesToRetrieve: ["*"], attributesToCrop: null, cropLength: 200, attributesToHighlight:
* null, filters: null, matches: false, facetsDistribution: null
* null, filter: null, matches: false, facetsDistribution: null
*
* @param q Query String
* @param offset Number of documents to skip
Expand All @@ -44,7 +44,7 @@ public SearchRequest(String q, int offset) {
/**
* Constructor for SearchRequest for building search queries with the default values:
* attributesToRetrieve: ["*"], attributesToCrop: null, cropLength: 200, attributesToHighlight:
* null, filters: null, matches: false, facetsDistribution: null
* null, filter: null, matches: false, facetsDistribution: null
*
* @param q Query String
* @param offset Number of documents to skip
Expand All @@ -56,7 +56,7 @@ public SearchRequest(String q, int offset, int limit) {

/**
* Constructor for SearchRequest for building search queries with the default values:
* attributesToCrop: null, cropLength: 200, attributesToHighlight: null, filters: null, matches:
* attributesToCrop: null, cropLength: 200, attributesToHighlight: null, filter: null, matches:
* false, facetsDistribution: null
*
* @param q Query String
Expand All @@ -78,7 +78,7 @@ public SearchRequest(String q, int offset, int limit, String[] attributesToRetri
* @param attributesToCrop Attributes whose values have been cropped
* @param cropLength Length used to crop field values
* @param attributesToHighlight Attributes whose values will contain highlighted matching terms
* @param filters Filter queries by an attribute value
* @param filter Filter queries by an attribute value
* @param matches Defines whether an object that contains information about the matches should
* be returned or not
* @param facetsDistribution Facets for which to retrieve the matching count
Expand All @@ -91,7 +91,7 @@ public SearchRequest(
String[] attributesToCrop,
int cropLength,
String[] attributesToHighlight,
String filters,
String filter,
boolean matches,
String[] facetsDistribution) {
this.q = q;
Expand All @@ -101,7 +101,7 @@ public SearchRequest(
this.attributesToCrop = attributesToCrop;
this.cropLength = cropLength;
this.attributesToHighlight = attributesToHighlight;
this.setFilters(filters);
this.setFilter(filter);
this.matches = matches;
this.facetsDistribution = facetsDistribution;
}
Expand Down Expand Up @@ -170,12 +170,12 @@ public String[] getAttributesToHighlight() {
}

/**
* Method to return the filters
* Method to return the filter
*
* @return filter queries by an attribute value
*/
public String getFilters() {
return filters;
public String getFilter() {
return filter;
}

/**
Expand Down Expand Up @@ -275,14 +275,14 @@ public SearchRequest setAttributesToHighlight(String[] attributesToHighlight) {
}

/**
* Method to set the filters
* Method to set the filter
*
* @param filters Filter queries by an attribute value
* @param filter Filter queries by an attribute value
* @return altered SearchRequest
*/
public SearchRequest setFilters(String filters) {
if (filters != null) {
this.filters = filters;
public SearchRequest setFilter(String filter) {
if (filter != null) {
this.filter = filter;
}
return this;
}
Expand Down Expand Up @@ -332,8 +332,8 @@ String getQuery() {
if (this.attributesToHighlight != null) {
jsonObject.put("attributesToHighlight", this.attributesToHighlight);
}
if (this.filters != null) {
jsonObject.put("filters", this.filters);
if (this.filter != null) {
jsonObject.put("filter", this.filter);
}
return jsonObject.toString();
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/meilisearch/sdk/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class Settings {
@Getter @Setter private HashMap<String, String[]> synonyms;
@Getter @Setter private String[] stopWords;
@Getter @Setter private String[] rankingRules;
@Getter @Setter private String[] attributesForFaceting;
@Getter @Setter private String[] filterableAttributes;
@Getter @Setter private String distinctAttribute;
@Getter @Setter private String[] searchableAttributes;
@Getter @Setter private String[] displayedAttributes;
Expand All @@ -38,8 +38,8 @@ String getUpdateQuery() {
if (this.getRankingRules() != null) {
jsonObject.put("rankingRules", this.getRankingRules());
}
if (this.getAttributesForFaceting() != null) {
jsonObject.put("attributesForFaceting", this.getAttributesForFaceting());
if (this.getFilterableAttributes() != null) {
jsonObject.put("filterableAttributes", this.getFilterableAttributes());
}
if (this.getDistinctAttribute() != null) {
jsonObject.put("distinctAttribute", this.getDistinctAttribute());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public class SearchRequest {
private final String q;
private final int offset;
private final int limit;
private final String filters;
private final String filter;
private final List<String> attributesToRetrieve;
private final List<String> attributesToCrop;
private final int cropLength;
Expand Down Expand Up @@ -38,7 +38,7 @@ public SearchRequest(
List<String> attributesToCrop,
int cropLength,
List<String> attributesToHighlight,
String filters,
String filter,
boolean matches) {
this.q = q;
this.offset = offset;
Expand All @@ -47,7 +47,7 @@ public SearchRequest(
this.attributesToCrop = attributesToCrop;
this.cropLength = cropLength;
this.attributesToHighlight = attributesToHighlight;
this.filters = filters;
this.filter = filter;
this.matches = matches;
}

Expand Down Expand Up @@ -79,8 +79,8 @@ public List<String> getAttributesToHighlight() {
return attributesToHighlight;
}

public String getFilters() {
return filters;
public String getFilter() {
return filter;
}

public boolean isMatches() {
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/com/meilisearch/sdk/api/index/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class Settings {
private HashMap<String, String[]> synonyms;
private String[] stopWords;
private String[] rankingRules;
private String[] attributesForFaceting;
private String[] filterableAttributes;
private String distinctAttribute;
private String[] searchableAttributes;
private String[] displayedAttributes;
Expand Down Expand Up @@ -45,12 +45,12 @@ public void setRankingRules(String[] rankingRules) {
this.rankingRules = rankingRules;
}

public String[] getAttributesForFaceting() {
return attributesForFaceting;
public String[] getFilterableAttributes() {
return filterableAttributes;
}

public void setAttributesForFaceting(String[] attributesForFaceting) {
this.attributesForFaceting = attributesForFaceting;
public void setFilterableAttributes(String[] filterableAttributes) {
this.filterableAttributes = filterableAttributes;
}

public String getDistinctAttribute() {
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/com/meilisearch/sdk/api/instance/IndexStats.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
public class IndexStats {
private int numberOfDocuments;
private boolean isIndexing;
private Map<String, Integer> fieldsDistribution;
private Map<String, Integer> fieldDistribution;

public IndexStats() {}

public IndexStats(
int numberOfDocuments, boolean isIndexing, Map<String, Integer> fieldsDistribution) {
int numberOfDocuments, boolean isIndexing, Map<String, Integer> fieldDistribution) {
this.numberOfDocuments = numberOfDocuments;
this.isIndexing = isIndexing;
this.fieldsDistribution = fieldsDistribution;
this.fieldDistribution = fieldDistribution;
}

public int getNumberOfDocuments() {
Expand All @@ -32,11 +32,11 @@ public void setIndexing(boolean indexing) {
isIndexing = indexing;
}

public Map<String, Integer> getFieldsDistribution() {
return fieldsDistribution;
public Map<String, Integer> getFieldDistribution() {
return fieldDistribution;
}

public void setFieldsDistribution(Map<String, Integer> fieldsDistribution) {
this.fieldsDistribution = fieldsDistribution;
public void setFieldDistribution(Map<String, Integer> fieldDistribution) {
this.fieldDistribution = fieldDistribution;
}
}
19 changes: 13 additions & 6 deletions src/test/java/com/meilisearch/integration/DocumentsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

@Tag("integration")
public class DocumentsTest extends AbstractIT {

@BeforeEach
public void initialize() {
this.setUp();
Expand Down Expand Up @@ -77,7 +76,10 @@ public void testAddDocumentsMultiple() throws Exception {
index.waitForPendingUpdate(updateInfo.getUpdateId());
Movie[] movies = this.gson.fromJson(index.getDocuments(), Movie[].class);
for (int i = 0; i < movies.length; i++) {
assertEquals(movies[i].getTitle(), testData.getData().get(i).getTitle());
Movie movie =
this.gson.fromJson(
index.getDocument(testData.getData().get(i).getId()), Movie.class);
assertEquals(movie.getTitle(), testData.getData().get(i).getTitle());
}
}

Expand Down Expand Up @@ -175,10 +177,12 @@ public void testGetDocuments() throws Exception {
Movie[] movies = this.gson.fromJson(index.getDocuments(), Movie[].class);
assertEquals(20, movies.length);
for (int i = 0; i < movies.length; i++) {
assertEquals(movies[i].getTitle(), testData.getData().get(i).getTitle());
assertEquals(movies[i].getId(), testData.getData().get(i).getId());
Movie movie =
this.gson.fromJson(
index.getDocument(testData.getData().get(i).getId()), Movie.class);
assertEquals(movie.getTitle(), testData.getData().get(i).getTitle());
String[] expectedGenres = testData.getData().get(i).getGenres();
String[] foundGenres = movies[i].getGenres();
String[] foundGenres = movie.getGenres();
for (int x = 0; x < expectedGenres.length; x++) {
assertEquals(expectedGenres[x], foundGenres[x]);
}
Expand All @@ -201,7 +205,10 @@ public void testGetDocumentsLimit() throws Exception {
Movie[] movies = this.gson.fromJson(index.getDocuments(limit), Movie[].class);
assertEquals(limit, movies.length);
for (int i = 0; i < movies.length; i++) {
assertEquals(movies[i].getId(), testData.getData().get(i).getId());
Movie movie =
this.gson.fromJson(
index.getDocument(testData.getData().get(i).getId()), Movie.class);
assertEquals(movie.getTitle(), testData.getData().get(i).getTitle());
}
}

Expand Down
Loading

0 comments on commit a8987c9

Please sign in to comment.