Skip to content

Commit

Permalink
Merge #343
Browse files Browse the repository at this point in the history
343: Changes related to the next Meilisearch release (v0.29.0) r=alallema a=meili-bot

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

This PR:
- gathers the changes related to the next Meilisearch release (v0.29.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).
- might eventually contain test failures until the Meilisearch v0.29.0 is out.

⚠️ This PR should NOT be merged until the next release of Meilisearch (v0.29.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._


Co-authored-by: meili-bot <74670311+meili-bot@users.noreply.github.com>
Co-authored-by: Bruno Casali <brunoocasali@gmail.com>
Co-authored-by: Amélie <alallema@users.noreply.github.com>
  • Loading branch information
4 people authored Oct 3, 2022
2 parents fccb8d4 + 7990f6b commit 022b258
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ searchRes, err := index.Search("wonder",

## 🤖 Compatibility with Meilisearch

This package only guarantees the compatibility with the [version v0.28.0 of Meilisearch](https://github.com/meilisearch/meilisearch/releases/tag/v0.28.0).
This package only guarantees the 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 client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,16 @@ func TestClient_CreateKey(t *testing.T) {
Indexes: []string{"movies", "games"},
},
},
{
name: "TestCreateKeyWithWildcardedAction",
client: defaultClient,
key: Key{
Name: "TestCreateKeyWithWildcardedAction",
Description: "TestCreateKeyWithWildcardedAction",
Actions: []string{"documents.*"},
Indexes: []string{"movies", "games"},
},
},
{
name: "TestCreateKeyWithUID",
client: defaultClient,
Expand Down
3 changes: 3 additions & 0 deletions index_search.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ func (i Index) Search(query string, request *SearchRequest) (*SearchResponse, er
if request.HighlightPostTag != "" {
searchPostRequestParams["highlightPostTag"] = request.HighlightPostTag
}
if request.MatchingStrategy != "" {
searchPostRequestParams["matchingStrategy"] = request.MatchingStrategy
}
if len(request.AttributesToRetrieve) != 0 {
searchPostRequestParams["attributesToRetrieve"] = request.AttributesToRetrieve
}
Expand Down
49 changes: 49 additions & 0 deletions index_search_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,55 @@ func TestIndex_Search(t *testing.T) {
Limit: 20,
},
},
{
name: "TestIndexSearchWithCustomMatchingStrategyAll",
args: args{
UID: "indexUID",
client: defaultClient,
query: "le prince",
request: SearchRequest{
Limit: 10,
AttributesToRetrieve: []string{"book_id","title"},
MatchingStrategy: "all",
},
},
want: &SearchResponse{
Hits: []interface{}{
map[string]interface{}{
"book_id": float64(456), "title": "Le Petit Prince",
},
},
EstimatedTotalHits: 1,
Offset: 0,
Limit: 10,
},
},
{
name: "TestIndexSearchWithCustomMatchingStrategyLast",
args: args{
UID: "indexUID",
client: defaultClient,
query: "prince",
request: SearchRequest{
Limit: 10,
AttributesToRetrieve: []string{"book_id","title"},
MatchingStrategy: "last",
},
},
want: &SearchResponse{
Hits: []interface{}{
map[string]interface{}{
"book_id": float64(456), "title": "Le Petit Prince",
},
map[string]interface{}{
"book_id": float64(4), "title": "Harry Potter and the Half-Blood Prince",
},
},
EstimatedTotalHits: 2,
Offset: 0,
Limit: 10,
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down
1 change: 1 addition & 0 deletions types.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ type SearchRequest struct {
AttributesToHighlight []string
HighlightPreTag string
HighlightPostTag string
MatchingStrategy string
Filter interface{}
ShowMatchesPosition bool
Facets []string
Expand Down
7 changes: 7 additions & 0 deletions types_easyjson.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 022b258

Please sign in to comment.