diff --git a/README.md b/README.md index 11c0170..29bf15d 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,7 @@ func demo() { } var data = make([]Player, 0) - total, err := meilisearch.Search("player", meilisearch.SearchPayload{ + total, err := index.Search(meilisearch.SearchPay load{ Query: "ronaldo", Filter: [][]string{ []string{"age > 40"}, diff --git a/search.go b/search.go index def0202..516ec79 100644 --- a/search.go +++ b/search.go @@ -9,9 +9,8 @@ import ( ms "github.com/meilisearch/meilisearch-go" ) -// Search return result from database -func Search(index string, payload SearchPayload, response interface{}) (int64, error) { - result, err := client.Index(index).Search(payload.Query, &ms.SearchRequest{ +func (i Index) Search(payload SearchPayload, response interface{}) (int64, error) { + result, err := getIndex(i.Name).Search(payload.Query, &ms.SearchRequest{ Offset: payload.Pagination.Offset, Limit: payload.Pagination.Limit, Filter: payload.Filter, @@ -23,7 +22,7 @@ func Search(index string, payload SearchPayload, response interface{}) (int64, e Source: "meilisearch.Search", Message: err.Error(), Data: logger.Map{ - "index": index, + "index": i.Name, "payload": payload, }, }) @@ -43,7 +42,7 @@ func Search(index string, payload SearchPayload, response interface{}) (int64, e Source: "meilisearch.Search", Message: err.Error(), Data: logger.Map{ - "index": index, + "index": i.Name, "payload": payload, "hits": result.Hits, },