Skip to content

Commit

Permalink
Merge #144
Browse files Browse the repository at this point in the history
144: Changes related to the next MeiliSearch release (v0.21.0) r=alallema 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 and code sample #165 
- Update `WaitForPendingUpdate` status #166 
- Rename `attributes_for_faceting` into `filterable_attributes` #167 
- Rename `Filters` into `Filter` #168 #181 
- Rename `FieldDistribution` #169
- Adding `FinishedAt` in Dump #170
- Rename fields `buildDate` into `commitDate` #171
- Fix tests and Add missing tests according to new features #172
- Update code sample file #176 #182

Co-authored-by: meili-bot <74670311+meili-bot@users.noreply.github.com>
Co-authored-by: Clémentine Urquizar <clementine@meilisearch.com>
Co-authored-by: alallema <amelie@meilisearch.com>
Co-authored-by: Amélie <alallema@users.noreply.github.com>
  • Loading branch information
5 people authored Aug 24, 2021
2 parents 7578104 + 1dbf876 commit 9957497
Show file tree
Hide file tree
Showing 14 changed files with 659 additions and 541 deletions.
74 changes: 36 additions & 38 deletions .code-samples.meilisearch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,10 @@ update_settings_1: |-
distinctAttribute := "movie_id"
settings := meilisearch.Settings{
RankingRules: []string{
"typo",
"words",
"typo",
"proximity",
"attribute",
"wordsPosition",
"exactness",
"desc(release_date)",
"desc(rank)",
Expand Down Expand Up @@ -127,11 +126,10 @@ get_ranking_rules_1: |-
client.Index("movies").GetRankingRules()
update_ranking_rules_1: |-
rankingRules := []string{
"typo",
"words",
"typo",
"proximity",
"attribute",
"wordsPosition",
"exactness",
"asc(release_date)",
"desc(rank)",
Expand All @@ -145,6 +143,16 @@ update_distinct_attribute_1: |-
client.Index("movies").UpdateDistinctAttribute("movie_id")
reset_distinct_attribute_1: |-
client.Index("movies").ResetDistinctAttribute()
get_filterable_attributes_1: |-
client.Index("movies").GetFilterableAttributes()
update_filterable_attributes_1: |-
filterableAttributes := []string{
"genres",
"director",
}
client.Index("movies").UpdateFilterableAttributes(&filterableAttributes)
reset_filterable_attributes_1: |-
client.Index("movies").ResetFilterableAttributes()
get_searchable_attributes_1: |-
client.Index("movies").GetSearchableAttributes()
update_searchable_attributes_1: |-
Expand All @@ -156,16 +164,6 @@ update_searchable_attributes_1: |-
client.Index("movies").UpdateSearchableAttributes(&searchableAttributes)
reset_searchable_attributes_1: |-
client.Index("movies").ResetSearchableAttributes()
get_attributes_for_faceting_1: |-
client.Index("movies").GetAttributesForFaceting()
update_attributes_for_faceting_1: |-
attributesForFaceting := []string{
"genres",
"director",
}
client.Index("movies").UpdateAttributesForFaceting(&attributesForFaceting)
reset_attributes_for_faceting_1: |-
client.Index("movies").ResetAttributesForFaceting()
get_displayed_attributes_1: |-
client.Index("movies").GetDisplayedAttributes()
update_displayed_attributes_1: |-
Expand Down Expand Up @@ -205,19 +203,19 @@ field_properties_guide_displayed_1: |-
client.Index("movies").UpdateDisplayedAttributes(&displayedAttributes)
filtering_guide_1: |-
resp, err := client.Index("movies").Search("Avengers", &meilisearch.SearchRequest{
Filters: "release_date > \"795484800\"",
Filter: "release_date > \"795484800\"",
})
filtering_guide_2: |-
resp, err := client.Index("movies").Search("Batman", &meilisearch.SearchRequest{
Filters: "release_date > 795484800 AND (director = \"Tim Burton\" OR director = \"Christopher Nolan\")",
Filter: "release_date > 795484800 AND (director = \"Tim Burton\" OR director = \"Christopher Nolan\")",
})
filtering_guide_3: |-
resp, err := client.Index("movies").Search("horror", &meilisearch.SearchRequest{
Filters: "director = \"Jordan Peele\"",
Filter: "director = \"Jordan Peele\"",
})
filtering_guide_4: |-
resp, err := client.Index("movies").Search("Planet of the Apes", &meilisearch.SearchRequest{
Filters: "rating >= 3 AND (NOT director = \"Tim Burton\"",
Filter: "rating >= 3 AND (NOT director = \"Tim Burton\"",
})
search_parameter_guide_query_1: |-
resp, err := client.Index("movies").Search("shifu", &meilisearch.SearchRequest{})
Expand All @@ -239,21 +237,19 @@ search_parameter_guide_crop_1: |-
CropLength: 10,
})
search_parameter_guide_highlight_1: |-
resp, err := client.Index("movies").Search("shifu", &meilisearch.SearchRequest{
resp, err := client.Index("movies").Search("winter feast", &meilisearch.SearchRequest{
AttributesToHighlight: []string{"overview"},
})
search_parameter_guide_filter_1: |-
resp, err := client.Index("movies").Search("n", &meilisearch.SearchRequest{
Filters: "title = Nightshift",
Filter: "title = Nightshift",
})
search_parameter_guide_filter_2: |-
resp, err := client.Index("movies").Search("n", &meilisearch.SearchRequest{
Filters: "title = \"Kung Fu Panda\"",
Filter: "title = \"Kung Fu Panda\"",
})
search_parameter_guide_matches_1: |-
resp, err := client.Index("movies").Search("n", &meilisearch.SearchRequest{
Filters: "title=\"Kung Fu Panda\"",
AttributesToHighlight: []string{"overview"},
resp, err := client.Index("movies").Search("winter feast", &meilisearch.SearchRequest{
Matches: true,
})
settings_guide_synonyms_1: |-
Expand All @@ -267,11 +263,10 @@ settings_guide_stop_words_1: |-
client.Index("movies").UpdateStopWords(&stopWords)
settings_guide_ranking_rules_1: |-
rankingRules := []string{
"typo",
"words",
"typo",
"proximity",
"attribute",
"wordsPosition",
"exactness",
"asc(release_date)",
"desc(rank)",
Expand Down Expand Up @@ -321,7 +316,7 @@ search_guide_1: |-
})
search_guide_2: |-
resp, err := client.Index("movies").Search("Avengers", &meilisearch.SearchRequest{
Filters: "release_date > \"795484800\"",
Filter: "release_date > \"795484800\"",
})
getting_started_add_documents_md: |-
```bash
Expand Down Expand Up @@ -358,6 +353,7 @@ getting_started_add_documents_md: |-
}
```
[About this SDK](https://github.com/meilisearch/meilisearch-go/)
getting_started_search_md: |-
```go
Expand All @@ -369,15 +365,15 @@ getting_started_search_md: |-
[About this SDK](https://github.com/meilisearch/meilisearch-go/)
faceted_search_update_settings_1: |-
resp, err := client.Index("movies").UpdateAttributesForFaceting(&[]string{
resp, err := client.Index("movies").UpdateFilterableAttributes(&[]string{
"director",
"genres",
})
faceted_search_facet_filters_1: |-
faceted_search_filter_1: |-
resp, err := client.Index("movies").Search("thriller", &meilisearch.SearchRequest{
FacetFilters: [][]string{
[]string{"genres:Horror", "genres:Mystery"},
[]string{"director:Jordan Peele"},
Filter: [][]string{
[]string{"genres = Horror", "genres = Mystery"},
[]string{"director = \"Jordan Peele\""},
},
})
faceted_search_facets_distribution_1: |-
Expand All @@ -386,18 +382,18 @@ faceted_search_facets_distribution_1: |-
"genres",
},
})
faceted_search_walkthrough_attributes_for_faceting_1: |-
resp, err := client.Index("movies").UpdateAttributesForFaceting(&[]string{
faceted_search_walkthrough_filterable_attributes_1: |-
resp, err := client.Index("movies").UpdateFilterableAttributes(&[]string{
"director",
"producer",
"genres",
"production_companies",
})
faceted_search_walkthrough_facet_filters_1: |-
faceted_search_walkthrough_filter_1: |-
resp, err := client.Index("movies").Search("thriller", &meilisearch.SearchRequest{
FacetFilters: [][]string{
[]string{"genres:Horror", "genres:Mystery"},
[]string{"director:Jordan Peele"},
Filter: [][]string{
[]string{"genres = Horror", "genres = Mystery"},
[]string{"director = \"Jordan Peele\""},
},
})
faceted_search_walkthrough_facets_distribution_1: |-
Expand All @@ -410,3 +406,5 @@ post_dump_1: |-
resp, err := client.CreateDump()
get_dump_status_1: |-
resp, err := client.GetDumpStatus("dump-uid")
phrase_search_1: |-
resp, err := client.Index("movies").Search("\"african american\" horror", &meilisearch.SearchRequest{})
19 changes: 9 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func main() {
}
```

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 @@ -149,10 +149,9 @@ All the supported options are described in the [search parameters](https://docs.

```go
func main() {
searchRes, err := client.Index("books").Search("prince",
searchRes, err := client.Index("books").Search("hob",
&meilisearch.SearchRequest{
AttributesToHighlight: []string{"*"},
Filters: "book_id > 10",
})
if err != nil {
fmt.Println(err)
Expand All @@ -168,24 +167,24 @@ JSON output:
{
"hits": [
{
"book_id": 456,
"title": "Le Petit Prince",
"book_id": 1344,
"title": "The Hobbit",
"_formatted": {
"book_id": 456,
"title": "Le Petit <em>Prince</em>"
"book_id": 1344,
"title": "The <em>Hob</em>bit"
}
}
],
"offset": 0,
"limit": 1,
"limit": 20,
"processingTimeMs": 0,
"query": "prince"
"query": "hob"
}
```

## 🤖 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
24 changes: 12 additions & 12 deletions client_index_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,9 @@ func TestClient_CreateIndex(t *testing.T) {
Method: "POST",
Function: "CreateIndex",
RequestToString: "{\"uid\":\"indexUID\"}",
ResponseToString: "{\"message\":\"Index indexUID already exists\",\"errorCode\":\"index_already_exists\",\"errorType\":\"invalid_request_error\",\"errorLink\":\"https://docs.meilisearch.com/errors#index_already_exists\"}",
ResponseToString: "{\"message\":\"Index already exists.\",\"errorCode\":\"index_already_exists\",\"errorType\":\"invalid_request_error\",\"errorLink\":\"https://docs.meilisearch.com/errors#index_already_exists\"}",
MeilisearchApiMessage: meilisearchApiMessage{
Message: "Index indexUID already exists",
Message: "Index already exists.",
ErrorCode: "index_already_exists",
ErrorType: "invalid_request_error",
ErrorLink: "https://docs.meilisearch.com/errors#index_already_exists",
Expand Down Expand Up @@ -233,9 +233,9 @@ func TestClient_DeleteIndex(t *testing.T) {
Method: "DELETE",
Function: "DeleteIndex",
RequestToString: "empty request",
ResponseToString: "{\"message\":\"Index 1 not found\",\"errorCode\":\"index_not_found\",\"errorType\":\"invalid_request_error\",\"errorLink\":\"https://docs.meilisearch.com/errors#index_not_found\"}",
ResponseToString: "{\"message\":\"Index \\\"1\\\" not found.\",\"errorCode\":\"index_not_found\",\"errorType\":\"invalid_request_error\",\"errorLink\":\"https://docs.meilisearch.com/errors#index_not_found\"}",
MeilisearchApiMessage: meilisearchApiMessage{
Message: "Index 1 not found",
Message: "Index \"1\" not found.",
ErrorCode: "index_not_found",
ErrorType: "invalid_request_error",
ErrorLink: "https://docs.meilisearch.com/errors#index_not_found",
Expand All @@ -260,9 +260,9 @@ func TestClient_DeleteIndex(t *testing.T) {
Method: "DELETE",
Function: "DeleteIndex",
RequestToString: "empty request",
ResponseToString: "{\"message\":\"Index 2 not found\",\"errorCode\":\"index_not_found\",\"errorType\":\"invalid_request_error\",\"errorLink\":\"https://docs.meilisearch.com/errors#index_not_found\"}",
ResponseToString: "{\"message\":\"Index \\\"2\\\" not found.\",\"errorCode\":\"index_not_found\",\"errorType\":\"invalid_request_error\",\"errorLink\":\"https://docs.meilisearch.com/errors#index_not_found\"}",
MeilisearchApiMessage: meilisearchApiMessage{
Message: "Index 2 not found",
Message: "Index \"2\" not found.",
ErrorCode: "index_not_found",
ErrorType: "invalid_request_error",
ErrorLink: "https://docs.meilisearch.com/errors#index_not_found"},
Expand All @@ -277,9 +277,9 @@ func TestClient_DeleteIndex(t *testing.T) {
Method: "DELETE",
Function: "DeleteIndex",
RequestToString: "empty request",
ResponseToString: "{\"message\":\"Index 3 not found\",\"errorCode\":\"index_not_found\",\"errorType\":\"invalid_request_error\",\"errorLink\":\"https://docs.meilisearch.com/errors#index_not_found\"}",
ResponseToString: "{\"message\":\"Index \\\"3\\\" not found.\",\"errorCode\":\"index_not_found\",\"errorType\":\"invalid_request_error\",\"errorLink\":\"https://docs.meilisearch.com/errors#index_not_found\"}",
MeilisearchApiMessage: meilisearchApiMessage{
Message: "Index 3 not found",
Message: "Index \"3\" not found.",
ErrorCode: "index_not_found",
ErrorType: "invalid_request_error",
ErrorLink: "https://docs.meilisearch.com/errors#index_not_found"},
Expand All @@ -291,9 +291,9 @@ func TestClient_DeleteIndex(t *testing.T) {
Method: "DELETE",
Function: "DeleteIndex",
RequestToString: "empty request",
ResponseToString: "{\"message\":\"Index 4 not found\",\"errorCode\":\"index_not_found\",\"errorType\":\"invalid_request_error\",\"errorLink\":\"https://docs.meilisearch.com/errors#index_not_found\"}",
ResponseToString: "{\"message\":\"Index \\\"4\\\" not found.\",\"errorCode\":\"index_not_found\",\"errorType\":\"invalid_request_error\",\"errorLink\":\"https://docs.meilisearch.com/errors#index_not_found\"}",
MeilisearchApiMessage: meilisearchApiMessage{
Message: "Index 4 not found",
Message: "Index \"4\" not found.",
ErrorCode: "index_not_found",
ErrorType: "invalid_request_error",
ErrorLink: "https://docs.meilisearch.com/errors#index_not_found"},
Expand All @@ -308,9 +308,9 @@ func TestClient_DeleteIndex(t *testing.T) {
Method: "DELETE",
Function: "DeleteIndex",
RequestToString: "empty request",
ResponseToString: "{\"message\":\"Index 5 not found\",\"errorCode\":\"index_not_found\",\"errorType\":\"invalid_request_error\",\"errorLink\":\"https://docs.meilisearch.com/errors#index_not_found\"}",
ResponseToString: "{\"message\":\"Index \\\"5\\\" not found.\",\"errorCode\":\"index_not_found\",\"errorType\":\"invalid_request_error\",\"errorLink\":\"https://docs.meilisearch.com/errors#index_not_found\"}",
MeilisearchApiMessage: meilisearchApiMessage{
Message: "Index 5 not found",
Message: "Index \"5\" not found.",
ErrorCode: "index_not_found",
ErrorType: "invalid_request_error",
ErrorLink: "https://docs.meilisearch.com/errors#index_not_found"},
Expand Down
1 change: 1 addition & 0 deletions client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ func TestClient_Version(t *testing.T) {
gotResp, err := tt.client.GetVersion()
require.NoError(t, err)
require.NotNil(t, gotResp, "Version() should not return nil value")
require.Equal(t, "0.21.0", gotResp.PkgVersion)
})
}
}
Expand Down
8 changes: 4 additions & 4 deletions index.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ type IndexInterface interface {
GetSynonyms() (resp *map[string][]string, err error)
UpdateSynonyms(request *map[string][]string) (resp *AsyncUpdateID, err error)
ResetSynonyms() (resp *AsyncUpdateID, err error)
GetAttributesForFaceting() (resp *[]string, err error)
UpdateAttributesForFaceting(request *[]string) (resp *AsyncUpdateID, err error)
ResetAttributesForFaceting() (resp *AsyncUpdateID, err error)
GetFilterableAttributes() (resp *[]string, err error)
UpdateFilterableAttributes(request *[]string) (resp *AsyncUpdateID, err error)
ResetFilterableAttributes() (resp *AsyncUpdateID, err error)

WaitForPendingUpdate(ctx context.Context, interval time.Duration, updateID *AsyncUpdateID) (UpdateStatus, error)
DefaultWaitForPendingUpdate(updateID *AsyncUpdateID) (UpdateStatus, error)
Expand Down Expand Up @@ -212,7 +212,7 @@ func (i Index) WaitForPendingUpdate(
if err != nil {
return UpdateStatusUnknown, nil
}
if update.Status != UpdateStatusEnqueued {
if update.Status != UpdateStatusEnqueued && update.Status != UpdateStatusProcessing {
return update.Status, nil
}
time.Sleep(interval)
Expand Down
Loading

0 comments on commit 9957497

Please sign in to comment.