From 4178159ba2463a40282e89ac9faab9e8fa2d6863 Mon Sep 17 00:00:00 2001 From: Miguel Targa Date: Tue, 23 Jul 2024 22:08:57 -0400 Subject: [PATCH 1/7] Add New Facet Search Method - https://www.meilisearch.com/docs/reference/api/facet_search --- index_facet_search.go | 60 ++++++++++++++++++++++++++++ index_facet_search_test.go | 80 ++++++++++++++++++++++++++++++++++++++ types.go | 15 +++++++ 3 files changed, 155 insertions(+) create mode 100644 index_facet_search.go create mode 100644 index_facet_search_test.go diff --git a/index_facet_search.go b/index_facet_search.go new file mode 100644 index 00000000..2a14c6b4 --- /dev/null +++ b/index_facet_search.go @@ -0,0 +1,60 @@ +package meilisearch + +import ( + "encoding/json" + "errors" + "net/http" +) + +var ErrNoFacetSearchRequest = errors.New("no search facet request provided") + +func (i Index) FacetSearch(request *FacetSearchRequest) (*json.RawMessage, error) { + if request == nil { + return nil, ErrNoFacetSearchRequest + } + + searchPostRequestParams := FacetSearchPostRequestParams(request) + + resp := &json.RawMessage{} + + req := internalRequest{ + endpoint: "/indexes/" + i.UID + "/facet-search", + method: http.MethodPost, + contentType: contentTypeJSON, + withRequest: searchPostRequestParams, + withResponse: resp, + acceptedStatusCodes: []int{http.StatusOK}, + functionName: "FacetSearch", + } + + if err := i.client.executeRequest(req); err != nil { + return nil, err + } + + return resp, nil +} + +func FacetSearchPostRequestParams(request *FacetSearchRequest) map[string]interface{} { + params := make(map[string]interface{}, 22) + + if request.Q != "" { + params["q"] = request.Q + } + if request.FacetName != "" { + params["facetName"] = request.FacetName + } + if request.FacetQuery != "" { + params["facetQuery"] = request.FacetQuery + } + if request.Filter != "" { + params["filter"] = request.Filter + } + if request.MatchingStrategy != "" { + params["matchingStrategy"] = request.MatchingStrategy + } + if len(request.AttributesToSearchOn) != 0 { + params["attributesToSearchOn"] = request.AttributesToSearchOn + } + + return params +} diff --git a/index_facet_search_test.go b/index_facet_search_test.go new file mode 100644 index 00000000..6858a616 --- /dev/null +++ b/index_facet_search_test.go @@ -0,0 +1,80 @@ +package meilisearch + +import ( + "encoding/json" + "testing" + + "github.com/stretchr/testify/require" +) + +func TestIndex_FacetSearch(t *testing.T) { + type args struct { + UID string + PrimaryKey string + client *Client + request *FacetSearchRequest + filterableAttributes []string + } + + tests := []struct { + name string + args args + want *FacetSearchResponse + wantErr bool + }{ + { + name: "TestIndexBasicFacetSearch", + args: args{ + UID: "indexUID", + client: defaultClient, + request: &FacetSearchRequest{ + FacetName: "tag", + FacetQuery: "Novel", + }, + filterableAttributes: []string{"tag"}, + }, + want: &FacetSearchResponse{ + FacetHits: []interface{}{ + map[string]interface{}{ + "value": "Novel", "count": float64(5), + }, + }, + FacetQuery: "Novel", + }, + wantErr: false, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + SetUpIndexForFaceting() + c := tt.args.client + i := c.Index(tt.args.UID) + t.Cleanup(cleanup(c)) + + updateFilter, err := i.UpdateFilterableAttributes(&tt.args.filterableAttributes) + require.NoError(t, err) + testWaitForTask(t, i, updateFilter) + + gotRaw, err := i.FacetSearch(tt.args.request) + + if tt.wantErr { + require.Error(t, err) + require.Nil(t, tt.want) + return + } + + require.NoError(t, err) + // Unmarshall the raw response from FacetSearch into a FacetSearchResponse + var got FacetSearchResponse + err = json.Unmarshal(*gotRaw, &got) + require.NoError(t, err, "error unmarshalling raw got FacetSearchResponse") + + require.Equal(t, len(tt.want.FacetHits), len(got.FacetHits)) + for len := range got.FacetHits { + require.Equal(t, tt.want.FacetHits[len].(map[string]interface{})["value"], got.FacetHits[len].(map[string]interface{})["value"]) + require.Equal(t, tt.want.FacetHits[len].(map[string]interface{})["count"], got.FacetHits[len].(map[string]interface{})["count"]) + } + require.Equal(t, tt.want.FacetQuery, got.FacetQuery) + }) + } +} diff --git a/types.go b/types.go index 126c06ca..cab5328a 100644 --- a/types.go +++ b/types.go @@ -394,6 +394,21 @@ type MultiSearchResponse struct { Results []SearchResponse `json:"results"` } +type FacetSearchRequest struct { + FacetName string `json:"facetName,omitempty"` + FacetQuery string `json:"facetQuery,omitempty"` + Q string `json:"q,omitempty"` + Filter string `json:"filter,omitempty"` + MatchingStrategy string `json:"matchingStrategy,omitempty"` + AttributesToSearchOn []string `json:"attributesToSearchOn,omitempty"` +} + +type FacetSearchResponse struct { + FacetHits []interface{} `json:"facetHits"` + FacetQuery string `json:"facetQuery"` + processingTimeMs int64 `json:"processingTimeMs"` +} + // DocumentQuery is the request body get one documents method type DocumentQuery struct { Fields []string `json:"fields,omitempty"` From 2310d3c674849a55c70d84cff4700e2d8e742bf6 Mon Sep 17 00:00:00 2001 From: Miguel Targa Date: Tue, 23 Jul 2024 22:17:36 -0400 Subject: [PATCH 2/7] Fix ProcessingTimeMs case --- types.go | 2 +- types_easyjson.go | 693 ++++++++++++++++++++++++++++++++-------------- 2 files changed, 488 insertions(+), 207 deletions(-) diff --git a/types.go b/types.go index cab5328a..fe7b3a4e 100644 --- a/types.go +++ b/types.go @@ -406,7 +406,7 @@ type FacetSearchRequest struct { type FacetSearchResponse struct { FacetHits []interface{} `json:"facetHits"` FacetQuery string `json:"facetQuery"` - processingTimeMs int64 `json:"processingTimeMs"` + ProcessingTimeMs int64 `json:"processingTimeMs"` } // DocumentQuery is the request body get one documents method diff --git a/types_easyjson.go b/types_easyjson.go index b8292390..d7408675 100644 --- a/types_easyjson.go +++ b/types_easyjson.go @@ -4312,7 +4312,288 @@ func (v *Faceting) UnmarshalJSON(data []byte) error { func (v *Faceting) UnmarshalEasyJSON(l *jlexer.Lexer) { easyjson6601e8cdDecodeGithubComMeilisearchMeilisearchGo30(l, v) } -func easyjson6601e8cdDecodeGithubComMeilisearchMeilisearchGo31(in *jlexer.Lexer, out *Embedder) { +func easyjson6601e8cdDecodeGithubComMeilisearchMeilisearchGo31(in *jlexer.Lexer, out *FacetSearchResponse) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeFieldName(false) + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "facetHits": + if in.IsNull() { + in.Skip() + out.FacetHits = nil + } else { + in.Delim('[') + if out.FacetHits == nil { + if !in.IsDelim(']') { + out.FacetHits = make([]interface{}, 0, 4) + } else { + out.FacetHits = []interface{}{} + } + } else { + out.FacetHits = (out.FacetHits)[:0] + } + for !in.IsDelim(']') { + var v105 interface{} + if m, ok := v105.(easyjson.Unmarshaler); ok { + m.UnmarshalEasyJSON(in) + } else if m, ok := v105.(json.Unmarshaler); ok { + _ = m.UnmarshalJSON(in.Raw()) + } else { + v105 = in.Interface() + } + out.FacetHits = append(out.FacetHits, v105) + in.WantComma() + } + in.Delim(']') + } + case "facetQuery": + out.FacetQuery = string(in.String()) + case "processingTimeMs": + out.ProcessingTimeMs = int64(in.Int64()) + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} +func easyjson6601e8cdEncodeGithubComMeilisearchMeilisearchGo31(out *jwriter.Writer, in FacetSearchResponse) { + out.RawByte('{') + first := true + _ = first + { + const prefix string = ",\"facetHits\":" + out.RawString(prefix[1:]) + if in.FacetHits == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 { + out.RawString("null") + } else { + out.RawByte('[') + for v106, v107 := range in.FacetHits { + if v106 > 0 { + out.RawByte(',') + } + if m, ok := v107.(easyjson.Marshaler); ok { + m.MarshalEasyJSON(out) + } else if m, ok := v107.(json.Marshaler); ok { + out.Raw(m.MarshalJSON()) + } else { + out.Raw(json.Marshal(v107)) + } + } + out.RawByte(']') + } + } + { + const prefix string = ",\"facetQuery\":" + out.RawString(prefix) + out.String(string(in.FacetQuery)) + } + { + const prefix string = ",\"processingTimeMs\":" + out.RawString(prefix) + out.Int64(int64(in.ProcessingTimeMs)) + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v FacetSearchResponse) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjson6601e8cdEncodeGithubComMeilisearchMeilisearchGo31(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v FacetSearchResponse) MarshalEasyJSON(w *jwriter.Writer) { + easyjson6601e8cdEncodeGithubComMeilisearchMeilisearchGo31(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *FacetSearchResponse) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjson6601e8cdDecodeGithubComMeilisearchMeilisearchGo31(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *FacetSearchResponse) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson6601e8cdDecodeGithubComMeilisearchMeilisearchGo31(l, v) +} +func easyjson6601e8cdDecodeGithubComMeilisearchMeilisearchGo32(in *jlexer.Lexer, out *FacetSearchRequest) { + isTopLevel := in.IsStart() + if in.IsNull() { + if isTopLevel { + in.Consumed() + } + in.Skip() + return + } + in.Delim('{') + for !in.IsDelim('}') { + key := in.UnsafeFieldName(false) + in.WantColon() + if in.IsNull() { + in.Skip() + in.WantComma() + continue + } + switch key { + case "facetName": + out.FacetName = string(in.String()) + case "facetQuery": + out.FacetQuery = string(in.String()) + case "q": + out.Q = string(in.String()) + case "filter": + out.Filter = string(in.String()) + case "matchingStrategy": + out.MatchingStrategy = string(in.String()) + case "attributesToSearchOn": + if in.IsNull() { + in.Skip() + out.AttributesToSearchOn = nil + } else { + in.Delim('[') + if out.AttributesToSearchOn == nil { + if !in.IsDelim(']') { + out.AttributesToSearchOn = make([]string, 0, 4) + } else { + out.AttributesToSearchOn = []string{} + } + } else { + out.AttributesToSearchOn = (out.AttributesToSearchOn)[:0] + } + for !in.IsDelim(']') { + var v108 string + v108 = string(in.String()) + out.AttributesToSearchOn = append(out.AttributesToSearchOn, v108) + in.WantComma() + } + in.Delim(']') + } + default: + in.SkipRecursive() + } + in.WantComma() + } + in.Delim('}') + if isTopLevel { + in.Consumed() + } +} +func easyjson6601e8cdEncodeGithubComMeilisearchMeilisearchGo32(out *jwriter.Writer, in FacetSearchRequest) { + out.RawByte('{') + first := true + _ = first + if in.FacetName != "" { + const prefix string = ",\"facetName\":" + first = false + out.RawString(prefix[1:]) + out.String(string(in.FacetName)) + } + if in.FacetQuery != "" { + const prefix string = ",\"facetQuery\":" + if first { + first = false + out.RawString(prefix[1:]) + } else { + out.RawString(prefix) + } + out.String(string(in.FacetQuery)) + } + if in.Q != "" { + const prefix string = ",\"q\":" + if first { + first = false + out.RawString(prefix[1:]) + } else { + out.RawString(prefix) + } + out.String(string(in.Q)) + } + if in.Filter != "" { + const prefix string = ",\"filter\":" + if first { + first = false + out.RawString(prefix[1:]) + } else { + out.RawString(prefix) + } + out.String(string(in.Filter)) + } + if in.MatchingStrategy != "" { + const prefix string = ",\"matchingStrategy\":" + if first { + first = false + out.RawString(prefix[1:]) + } else { + out.RawString(prefix) + } + out.String(string(in.MatchingStrategy)) + } + if len(in.AttributesToSearchOn) != 0 { + const prefix string = ",\"attributesToSearchOn\":" + if first { + first = false + out.RawString(prefix[1:]) + } else { + out.RawString(prefix) + } + { + out.RawByte('[') + for v109, v110 := range in.AttributesToSearchOn { + if v109 > 0 { + out.RawByte(',') + } + out.String(string(v110)) + } + out.RawByte(']') + } + } + out.RawByte('}') +} + +// MarshalJSON supports json.Marshaler interface +func (v FacetSearchRequest) MarshalJSON() ([]byte, error) { + w := jwriter.Writer{} + easyjson6601e8cdEncodeGithubComMeilisearchMeilisearchGo32(&w, v) + return w.Buffer.BuildBytes(), w.Error +} + +// MarshalEasyJSON supports easyjson.Marshaler interface +func (v FacetSearchRequest) MarshalEasyJSON(w *jwriter.Writer) { + easyjson6601e8cdEncodeGithubComMeilisearchMeilisearchGo32(w, v) +} + +// UnmarshalJSON supports json.Unmarshaler interface +func (v *FacetSearchRequest) UnmarshalJSON(data []byte) error { + r := jlexer.Lexer{Data: data} + easyjson6601e8cdDecodeGithubComMeilisearchMeilisearchGo32(&r, v) + return r.Error() +} + +// UnmarshalEasyJSON supports easyjson.Unmarshaler interface +func (v *FacetSearchRequest) UnmarshalEasyJSON(l *jlexer.Lexer) { + easyjson6601e8cdDecodeGithubComMeilisearchMeilisearchGo32(l, v) +} +func easyjson6601e8cdDecodeGithubComMeilisearchMeilisearchGo33(in *jlexer.Lexer, out *Embedder) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -4351,7 +4632,7 @@ func easyjson6601e8cdDecodeGithubComMeilisearchMeilisearchGo31(in *jlexer.Lexer, in.Consumed() } } -func easyjson6601e8cdEncodeGithubComMeilisearchMeilisearchGo31(out *jwriter.Writer, in Embedder) { +func easyjson6601e8cdEncodeGithubComMeilisearchMeilisearchGo33(out *jwriter.Writer, in Embedder) { out.RawByte('{') first := true _ = first @@ -4386,27 +4667,27 @@ func easyjson6601e8cdEncodeGithubComMeilisearchMeilisearchGo31(out *jwriter.Writ // MarshalJSON supports json.Marshaler interface func (v Embedder) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - easyjson6601e8cdEncodeGithubComMeilisearchMeilisearchGo31(&w, v) + easyjson6601e8cdEncodeGithubComMeilisearchMeilisearchGo33(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface func (v Embedder) MarshalEasyJSON(w *jwriter.Writer) { - easyjson6601e8cdEncodeGithubComMeilisearchMeilisearchGo31(w, v) + easyjson6601e8cdEncodeGithubComMeilisearchMeilisearchGo33(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *Embedder) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjson6601e8cdDecodeGithubComMeilisearchMeilisearchGo31(&r, v) + easyjson6601e8cdDecodeGithubComMeilisearchMeilisearchGo33(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface func (v *Embedder) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjson6601e8cdDecodeGithubComMeilisearchMeilisearchGo31(l, v) + easyjson6601e8cdDecodeGithubComMeilisearchMeilisearchGo33(l, v) } -func easyjson6601e8cdDecodeGithubComMeilisearchMeilisearchGo32(in *jlexer.Lexer, out *DocumentsResult) { +func easyjson6601e8cdDecodeGithubComMeilisearchMeilisearchGo34(in *jlexer.Lexer, out *DocumentsResult) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -4441,29 +4722,29 @@ func easyjson6601e8cdDecodeGithubComMeilisearchMeilisearchGo32(in *jlexer.Lexer, out.Results = (out.Results)[:0] } for !in.IsDelim(']') { - var v105 map[string]interface{} + var v111 map[string]interface{} if in.IsNull() { in.Skip() } else { in.Delim('{') - v105 = make(map[string]interface{}) + v111 = make(map[string]interface{}) for !in.IsDelim('}') { key := string(in.String()) in.WantColon() - var v106 interface{} - if m, ok := v106.(easyjson.Unmarshaler); ok { + var v112 interface{} + if m, ok := v112.(easyjson.Unmarshaler); ok { m.UnmarshalEasyJSON(in) - } else if m, ok := v106.(json.Unmarshaler); ok { + } else if m, ok := v112.(json.Unmarshaler); ok { _ = m.UnmarshalJSON(in.Raw()) } else { - v106 = in.Interface() + v112 = in.Interface() } - (v105)[key] = v106 + (v111)[key] = v112 in.WantComma() } in.Delim('}') } - out.Results = append(out.Results, v105) + out.Results = append(out.Results, v111) in.WantComma() } in.Delim(']') @@ -4484,7 +4765,7 @@ func easyjson6601e8cdDecodeGithubComMeilisearchMeilisearchGo32(in *jlexer.Lexer, in.Consumed() } } -func easyjson6601e8cdEncodeGithubComMeilisearchMeilisearchGo32(out *jwriter.Writer, in DocumentsResult) { +func easyjson6601e8cdEncodeGithubComMeilisearchMeilisearchGo34(out *jwriter.Writer, in DocumentsResult) { out.RawByte('{') first := true _ = first @@ -4495,29 +4776,29 @@ func easyjson6601e8cdEncodeGithubComMeilisearchMeilisearchGo32(out *jwriter.Writ out.RawString("null") } else { out.RawByte('[') - for v107, v108 := range in.Results { - if v107 > 0 { + for v113, v114 := range in.Results { + if v113 > 0 { out.RawByte(',') } - if v108 == nil && (out.Flags&jwriter.NilMapAsEmpty) == 0 { + if v114 == nil && (out.Flags&jwriter.NilMapAsEmpty) == 0 { out.RawString(`null`) } else { out.RawByte('{') - v109First := true - for v109Name, v109Value := range v108 { - if v109First { - v109First = false + v115First := true + for v115Name, v115Value := range v114 { + if v115First { + v115First = false } else { out.RawByte(',') } - out.String(string(v109Name)) + out.String(string(v115Name)) out.RawByte(':') - if m, ok := v109Value.(easyjson.Marshaler); ok { + if m, ok := v115Value.(easyjson.Marshaler); ok { m.MarshalEasyJSON(out) - } else if m, ok := v109Value.(json.Marshaler); ok { + } else if m, ok := v115Value.(json.Marshaler); ok { out.Raw(m.MarshalJSON()) } else { - out.Raw(json.Marshal(v109Value)) + out.Raw(json.Marshal(v115Value)) } } out.RawByte('}') @@ -4547,27 +4828,27 @@ func easyjson6601e8cdEncodeGithubComMeilisearchMeilisearchGo32(out *jwriter.Writ // MarshalJSON supports json.Marshaler interface func (v DocumentsResult) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - easyjson6601e8cdEncodeGithubComMeilisearchMeilisearchGo32(&w, v) + easyjson6601e8cdEncodeGithubComMeilisearchMeilisearchGo34(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface func (v DocumentsResult) MarshalEasyJSON(w *jwriter.Writer) { - easyjson6601e8cdEncodeGithubComMeilisearchMeilisearchGo32(w, v) + easyjson6601e8cdEncodeGithubComMeilisearchMeilisearchGo34(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *DocumentsResult) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjson6601e8cdDecodeGithubComMeilisearchMeilisearchGo32(&r, v) + easyjson6601e8cdDecodeGithubComMeilisearchMeilisearchGo34(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface func (v *DocumentsResult) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjson6601e8cdDecodeGithubComMeilisearchMeilisearchGo32(l, v) + easyjson6601e8cdDecodeGithubComMeilisearchMeilisearchGo34(l, v) } -func easyjson6601e8cdDecodeGithubComMeilisearchMeilisearchGo33(in *jlexer.Lexer, out *DocumentsQuery) { +func easyjson6601e8cdDecodeGithubComMeilisearchMeilisearchGo35(in *jlexer.Lexer, out *DocumentsQuery) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -4606,9 +4887,9 @@ func easyjson6601e8cdDecodeGithubComMeilisearchMeilisearchGo33(in *jlexer.Lexer, out.Fields = (out.Fields)[:0] } for !in.IsDelim(']') { - var v110 string - v110 = string(in.String()) - out.Fields = append(out.Fields, v110) + var v116 string + v116 = string(in.String()) + out.Fields = append(out.Fields, v116) in.WantComma() } in.Delim(']') @@ -4631,7 +4912,7 @@ func easyjson6601e8cdDecodeGithubComMeilisearchMeilisearchGo33(in *jlexer.Lexer, in.Consumed() } } -func easyjson6601e8cdEncodeGithubComMeilisearchMeilisearchGo33(out *jwriter.Writer, in DocumentsQuery) { +func easyjson6601e8cdEncodeGithubComMeilisearchMeilisearchGo35(out *jwriter.Writer, in DocumentsQuery) { out.RawByte('{') first := true _ = first @@ -4661,11 +4942,11 @@ func easyjson6601e8cdEncodeGithubComMeilisearchMeilisearchGo33(out *jwriter.Writ } { out.RawByte('[') - for v111, v112 := range in.Fields { - if v111 > 0 { + for v117, v118 := range in.Fields { + if v117 > 0 { out.RawByte(',') } - out.String(string(v112)) + out.String(string(v118)) } out.RawByte(']') } @@ -4692,27 +4973,27 @@ func easyjson6601e8cdEncodeGithubComMeilisearchMeilisearchGo33(out *jwriter.Writ // MarshalJSON supports json.Marshaler interface func (v DocumentsQuery) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - easyjson6601e8cdEncodeGithubComMeilisearchMeilisearchGo33(&w, v) + easyjson6601e8cdEncodeGithubComMeilisearchMeilisearchGo35(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface func (v DocumentsQuery) MarshalEasyJSON(w *jwriter.Writer) { - easyjson6601e8cdEncodeGithubComMeilisearchMeilisearchGo33(w, v) + easyjson6601e8cdEncodeGithubComMeilisearchMeilisearchGo35(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *DocumentsQuery) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjson6601e8cdDecodeGithubComMeilisearchMeilisearchGo33(&r, v) + easyjson6601e8cdDecodeGithubComMeilisearchMeilisearchGo35(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface func (v *DocumentsQuery) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjson6601e8cdDecodeGithubComMeilisearchMeilisearchGo33(l, v) + easyjson6601e8cdDecodeGithubComMeilisearchMeilisearchGo35(l, v) } -func easyjson6601e8cdDecodeGithubComMeilisearchMeilisearchGo34(in *jlexer.Lexer, out *DocumentQuery) { +func easyjson6601e8cdDecodeGithubComMeilisearchMeilisearchGo36(in *jlexer.Lexer, out *DocumentQuery) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -4747,9 +5028,9 @@ func easyjson6601e8cdDecodeGithubComMeilisearchMeilisearchGo34(in *jlexer.Lexer, out.Fields = (out.Fields)[:0] } for !in.IsDelim(']') { - var v113 string - v113 = string(in.String()) - out.Fields = append(out.Fields, v113) + var v119 string + v119 = string(in.String()) + out.Fields = append(out.Fields, v119) in.WantComma() } in.Delim(']') @@ -4764,7 +5045,7 @@ func easyjson6601e8cdDecodeGithubComMeilisearchMeilisearchGo34(in *jlexer.Lexer, in.Consumed() } } -func easyjson6601e8cdEncodeGithubComMeilisearchMeilisearchGo34(out *jwriter.Writer, in DocumentQuery) { +func easyjson6601e8cdEncodeGithubComMeilisearchMeilisearchGo36(out *jwriter.Writer, in DocumentQuery) { out.RawByte('{') first := true _ = first @@ -4774,11 +5055,11 @@ func easyjson6601e8cdEncodeGithubComMeilisearchMeilisearchGo34(out *jwriter.Writ out.RawString(prefix[1:]) { out.RawByte('[') - for v114, v115 := range in.Fields { - if v114 > 0 { + for v120, v121 := range in.Fields { + if v120 > 0 { out.RawByte(',') } - out.String(string(v115)) + out.String(string(v121)) } out.RawByte(']') } @@ -4789,27 +5070,27 @@ func easyjson6601e8cdEncodeGithubComMeilisearchMeilisearchGo34(out *jwriter.Writ // MarshalJSON supports json.Marshaler interface func (v DocumentQuery) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - easyjson6601e8cdEncodeGithubComMeilisearchMeilisearchGo34(&w, v) + easyjson6601e8cdEncodeGithubComMeilisearchMeilisearchGo36(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface func (v DocumentQuery) MarshalEasyJSON(w *jwriter.Writer) { - easyjson6601e8cdEncodeGithubComMeilisearchMeilisearchGo34(w, v) + easyjson6601e8cdEncodeGithubComMeilisearchMeilisearchGo36(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *DocumentQuery) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjson6601e8cdDecodeGithubComMeilisearchMeilisearchGo34(&r, v) + easyjson6601e8cdDecodeGithubComMeilisearchMeilisearchGo36(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface func (v *DocumentQuery) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjson6601e8cdDecodeGithubComMeilisearchMeilisearchGo34(l, v) + easyjson6601e8cdDecodeGithubComMeilisearchMeilisearchGo36(l, v) } -func easyjson6601e8cdDecodeGithubComMeilisearchMeilisearchGo35(in *jlexer.Lexer, out *Details) { +func easyjson6601e8cdDecodeGithubComMeilisearchMeilisearchGo37(in *jlexer.Lexer, out *Details) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -4854,9 +5135,9 @@ func easyjson6601e8cdDecodeGithubComMeilisearchMeilisearchGo35(in *jlexer.Lexer, out.RankingRules = (out.RankingRules)[:0] } for !in.IsDelim(']') { - var v116 string - v116 = string(in.String()) - out.RankingRules = append(out.RankingRules, v116) + var v122 string + v122 = string(in.String()) + out.RankingRules = append(out.RankingRules, v122) in.WantComma() } in.Delim(']') @@ -4887,9 +5168,9 @@ func easyjson6601e8cdDecodeGithubComMeilisearchMeilisearchGo35(in *jlexer.Lexer, out.SearchableAttributes = (out.SearchableAttributes)[:0] } for !in.IsDelim(']') { - var v117 string - v117 = string(in.String()) - out.SearchableAttributes = append(out.SearchableAttributes, v117) + var v123 string + v123 = string(in.String()) + out.SearchableAttributes = append(out.SearchableAttributes, v123) in.WantComma() } in.Delim(']') @@ -4910,9 +5191,9 @@ func easyjson6601e8cdDecodeGithubComMeilisearchMeilisearchGo35(in *jlexer.Lexer, out.DisplayedAttributes = (out.DisplayedAttributes)[:0] } for !in.IsDelim(']') { - var v118 string - v118 = string(in.String()) - out.DisplayedAttributes = append(out.DisplayedAttributes, v118) + var v124 string + v124 = string(in.String()) + out.DisplayedAttributes = append(out.DisplayedAttributes, v124) in.WantComma() } in.Delim(']') @@ -4933,9 +5214,9 @@ func easyjson6601e8cdDecodeGithubComMeilisearchMeilisearchGo35(in *jlexer.Lexer, out.StopWords = (out.StopWords)[:0] } for !in.IsDelim(']') { - var v119 string - v119 = string(in.String()) - out.StopWords = append(out.StopWords, v119) + var v125 string + v125 = string(in.String()) + out.StopWords = append(out.StopWords, v125) in.WantComma() } in.Delim(']') @@ -4953,30 +5234,30 @@ func easyjson6601e8cdDecodeGithubComMeilisearchMeilisearchGo35(in *jlexer.Lexer, for !in.IsDelim('}') { key := string(in.String()) in.WantColon() - var v120 []string + var v126 []string if in.IsNull() { in.Skip() - v120 = nil + v126 = nil } else { in.Delim('[') - if v120 == nil { + if v126 == nil { if !in.IsDelim(']') { - v120 = make([]string, 0, 4) + v126 = make([]string, 0, 4) } else { - v120 = []string{} + v126 = []string{} } } else { - v120 = (v120)[:0] + v126 = (v126)[:0] } for !in.IsDelim(']') { - var v121 string - v121 = string(in.String()) - v120 = append(v120, v121) + var v127 string + v127 = string(in.String()) + v126 = append(v126, v127) in.WantComma() } in.Delim(']') } - (out.Synonyms)[key] = v120 + (out.Synonyms)[key] = v126 in.WantComma() } in.Delim('}') @@ -4997,9 +5278,9 @@ func easyjson6601e8cdDecodeGithubComMeilisearchMeilisearchGo35(in *jlexer.Lexer, out.FilterableAttributes = (out.FilterableAttributes)[:0] } for !in.IsDelim(']') { - var v122 string - v122 = string(in.String()) - out.FilterableAttributes = append(out.FilterableAttributes, v122) + var v128 string + v128 = string(in.String()) + out.FilterableAttributes = append(out.FilterableAttributes, v128) in.WantComma() } in.Delim(']') @@ -5020,9 +5301,9 @@ func easyjson6601e8cdDecodeGithubComMeilisearchMeilisearchGo35(in *jlexer.Lexer, out.SortableAttributes = (out.SortableAttributes)[:0] } for !in.IsDelim(']') { - var v123 string - v123 = string(in.String()) - out.SortableAttributes = append(out.SortableAttributes, v123) + var v129 string + v129 = string(in.String()) + out.SortableAttributes = append(out.SortableAttributes, v129) in.WantComma() } in.Delim(']') @@ -5081,9 +5362,9 @@ func easyjson6601e8cdDecodeGithubComMeilisearchMeilisearchGo35(in *jlexer.Lexer, out.Swaps = (out.Swaps)[:0] } for !in.IsDelim(']') { - var v124 SwapIndexesParams - (v124).UnmarshalEasyJSON(in) - out.Swaps = append(out.Swaps, v124) + var v130 SwapIndexesParams + (v130).UnmarshalEasyJSON(in) + out.Swaps = append(out.Swaps, v130) in.WantComma() } in.Delim(']') @@ -5100,7 +5381,7 @@ func easyjson6601e8cdDecodeGithubComMeilisearchMeilisearchGo35(in *jlexer.Lexer, in.Consumed() } } -func easyjson6601e8cdEncodeGithubComMeilisearchMeilisearchGo35(out *jwriter.Writer, in Details) { +func easyjson6601e8cdEncodeGithubComMeilisearchMeilisearchGo37(out *jwriter.Writer, in Details) { out.RawByte('{') first := true _ = first @@ -5160,11 +5441,11 @@ func easyjson6601e8cdEncodeGithubComMeilisearchMeilisearchGo35(out *jwriter.Writ } { out.RawByte('[') - for v125, v126 := range in.RankingRules { - if v125 > 0 { + for v131, v132 := range in.RankingRules { + if v131 > 0 { out.RawByte(',') } - out.String(string(v126)) + out.String(string(v132)) } out.RawByte(']') } @@ -5189,11 +5470,11 @@ func easyjson6601e8cdEncodeGithubComMeilisearchMeilisearchGo35(out *jwriter.Writ } { out.RawByte('[') - for v127, v128 := range in.SearchableAttributes { - if v127 > 0 { + for v133, v134 := range in.SearchableAttributes { + if v133 > 0 { out.RawByte(',') } - out.String(string(v128)) + out.String(string(v134)) } out.RawByte(']') } @@ -5208,11 +5489,11 @@ func easyjson6601e8cdEncodeGithubComMeilisearchMeilisearchGo35(out *jwriter.Writ } { out.RawByte('[') - for v129, v130 := range in.DisplayedAttributes { - if v129 > 0 { + for v135, v136 := range in.DisplayedAttributes { + if v135 > 0 { out.RawByte(',') } - out.String(string(v130)) + out.String(string(v136)) } out.RawByte(']') } @@ -5227,11 +5508,11 @@ func easyjson6601e8cdEncodeGithubComMeilisearchMeilisearchGo35(out *jwriter.Writ } { out.RawByte('[') - for v131, v132 := range in.StopWords { - if v131 > 0 { + for v137, v138 := range in.StopWords { + if v137 > 0 { out.RawByte(',') } - out.String(string(v132)) + out.String(string(v138)) } out.RawByte(']') } @@ -5246,24 +5527,24 @@ func easyjson6601e8cdEncodeGithubComMeilisearchMeilisearchGo35(out *jwriter.Writ } { out.RawByte('{') - v133First := true - for v133Name, v133Value := range in.Synonyms { - if v133First { - v133First = false + v139First := true + for v139Name, v139Value := range in.Synonyms { + if v139First { + v139First = false } else { out.RawByte(',') } - out.String(string(v133Name)) + out.String(string(v139Name)) out.RawByte(':') - if v133Value == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 { + if v139Value == nil && (out.Flags&jwriter.NilSliceAsEmpty) == 0 { out.RawString("null") } else { out.RawByte('[') - for v134, v135 := range v133Value { - if v134 > 0 { + for v140, v141 := range v139Value { + if v140 > 0 { out.RawByte(',') } - out.String(string(v135)) + out.String(string(v141)) } out.RawByte(']') } @@ -5281,11 +5562,11 @@ func easyjson6601e8cdEncodeGithubComMeilisearchMeilisearchGo35(out *jwriter.Writ } { out.RawByte('[') - for v136, v137 := range in.FilterableAttributes { - if v136 > 0 { + for v142, v143 := range in.FilterableAttributes { + if v142 > 0 { out.RawByte(',') } - out.String(string(v137)) + out.String(string(v143)) } out.RawByte(']') } @@ -5300,11 +5581,11 @@ func easyjson6601e8cdEncodeGithubComMeilisearchMeilisearchGo35(out *jwriter.Writ } { out.RawByte('[') - for v138, v139 := range in.SortableAttributes { - if v138 > 0 { + for v144, v145 := range in.SortableAttributes { + if v144 > 0 { out.RawByte(',') } - out.String(string(v139)) + out.String(string(v145)) } out.RawByte(']') } @@ -5389,11 +5670,11 @@ func easyjson6601e8cdEncodeGithubComMeilisearchMeilisearchGo35(out *jwriter.Writ } { out.RawByte('[') - for v140, v141 := range in.Swaps { - if v140 > 0 { + for v146, v147 := range in.Swaps { + if v146 > 0 { out.RawByte(',') } - (v141).MarshalEasyJSON(out) + (v147).MarshalEasyJSON(out) } out.RawByte(']') } @@ -5414,27 +5695,27 @@ func easyjson6601e8cdEncodeGithubComMeilisearchMeilisearchGo35(out *jwriter.Writ // MarshalJSON supports json.Marshaler interface func (v Details) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - easyjson6601e8cdEncodeGithubComMeilisearchMeilisearchGo35(&w, v) + easyjson6601e8cdEncodeGithubComMeilisearchMeilisearchGo37(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface func (v Details) MarshalEasyJSON(w *jwriter.Writer) { - easyjson6601e8cdEncodeGithubComMeilisearchMeilisearchGo35(w, v) + easyjson6601e8cdEncodeGithubComMeilisearchMeilisearchGo37(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *Details) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjson6601e8cdDecodeGithubComMeilisearchMeilisearchGo35(&r, v) + easyjson6601e8cdDecodeGithubComMeilisearchMeilisearchGo37(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface func (v *Details) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjson6601e8cdDecodeGithubComMeilisearchMeilisearchGo35(l, v) + easyjson6601e8cdDecodeGithubComMeilisearchMeilisearchGo37(l, v) } -func easyjson6601e8cdDecodeGithubComMeilisearchMeilisearchGo36(in *jlexer.Lexer, out *DeleteTasksQuery) { +func easyjson6601e8cdDecodeGithubComMeilisearchMeilisearchGo38(in *jlexer.Lexer, out *DeleteTasksQuery) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -5469,9 +5750,9 @@ func easyjson6601e8cdDecodeGithubComMeilisearchMeilisearchGo36(in *jlexer.Lexer, out.UIDS = (out.UIDS)[:0] } for !in.IsDelim(']') { - var v142 int64 - v142 = int64(in.Int64()) - out.UIDS = append(out.UIDS, v142) + var v148 int64 + v148 = int64(in.Int64()) + out.UIDS = append(out.UIDS, v148) in.WantComma() } in.Delim(']') @@ -5492,9 +5773,9 @@ func easyjson6601e8cdDecodeGithubComMeilisearchMeilisearchGo36(in *jlexer.Lexer, out.IndexUIDS = (out.IndexUIDS)[:0] } for !in.IsDelim(']') { - var v143 string - v143 = string(in.String()) - out.IndexUIDS = append(out.IndexUIDS, v143) + var v149 string + v149 = string(in.String()) + out.IndexUIDS = append(out.IndexUIDS, v149) in.WantComma() } in.Delim(']') @@ -5515,9 +5796,9 @@ func easyjson6601e8cdDecodeGithubComMeilisearchMeilisearchGo36(in *jlexer.Lexer, out.Statuses = (out.Statuses)[:0] } for !in.IsDelim(']') { - var v144 TaskStatus - v144 = TaskStatus(in.String()) - out.Statuses = append(out.Statuses, v144) + var v150 TaskStatus + v150 = TaskStatus(in.String()) + out.Statuses = append(out.Statuses, v150) in.WantComma() } in.Delim(']') @@ -5538,9 +5819,9 @@ func easyjson6601e8cdDecodeGithubComMeilisearchMeilisearchGo36(in *jlexer.Lexer, out.Types = (out.Types)[:0] } for !in.IsDelim(']') { - var v145 TaskType - v145 = TaskType(in.String()) - out.Types = append(out.Types, v145) + var v151 TaskType + v151 = TaskType(in.String()) + out.Types = append(out.Types, v151) in.WantComma() } in.Delim(']') @@ -5561,9 +5842,9 @@ func easyjson6601e8cdDecodeGithubComMeilisearchMeilisearchGo36(in *jlexer.Lexer, out.CanceledBy = (out.CanceledBy)[:0] } for !in.IsDelim(']') { - var v146 int64 - v146 = int64(in.Int64()) - out.CanceledBy = append(out.CanceledBy, v146) + var v152 int64 + v152 = int64(in.Int64()) + out.CanceledBy = append(out.CanceledBy, v152) in.WantComma() } in.Delim(']') @@ -5602,7 +5883,7 @@ func easyjson6601e8cdDecodeGithubComMeilisearchMeilisearchGo36(in *jlexer.Lexer, in.Consumed() } } -func easyjson6601e8cdEncodeGithubComMeilisearchMeilisearchGo36(out *jwriter.Writer, in DeleteTasksQuery) { +func easyjson6601e8cdEncodeGithubComMeilisearchMeilisearchGo38(out *jwriter.Writer, in DeleteTasksQuery) { out.RawByte('{') first := true _ = first @@ -5613,11 +5894,11 @@ func easyjson6601e8cdEncodeGithubComMeilisearchMeilisearchGo36(out *jwriter.Writ out.RawString("null") } else { out.RawByte('[') - for v147, v148 := range in.UIDS { - if v147 > 0 { + for v153, v154 := range in.UIDS { + if v153 > 0 { out.RawByte(',') } - out.Int64(int64(v148)) + out.Int64(int64(v154)) } out.RawByte(']') } @@ -5629,11 +5910,11 @@ func easyjson6601e8cdEncodeGithubComMeilisearchMeilisearchGo36(out *jwriter.Writ out.RawString("null") } else { out.RawByte('[') - for v149, v150 := range in.IndexUIDS { - if v149 > 0 { + for v155, v156 := range in.IndexUIDS { + if v155 > 0 { out.RawByte(',') } - out.String(string(v150)) + out.String(string(v156)) } out.RawByte(']') } @@ -5645,11 +5926,11 @@ func easyjson6601e8cdEncodeGithubComMeilisearchMeilisearchGo36(out *jwriter.Writ out.RawString("null") } else { out.RawByte('[') - for v151, v152 := range in.Statuses { - if v151 > 0 { + for v157, v158 := range in.Statuses { + if v157 > 0 { out.RawByte(',') } - out.String(string(v152)) + out.String(string(v158)) } out.RawByte(']') } @@ -5661,11 +5942,11 @@ func easyjson6601e8cdEncodeGithubComMeilisearchMeilisearchGo36(out *jwriter.Writ out.RawString("null") } else { out.RawByte('[') - for v153, v154 := range in.Types { - if v153 > 0 { + for v159, v160 := range in.Types { + if v159 > 0 { out.RawByte(',') } - out.String(string(v154)) + out.String(string(v160)) } out.RawByte(']') } @@ -5677,11 +5958,11 @@ func easyjson6601e8cdEncodeGithubComMeilisearchMeilisearchGo36(out *jwriter.Writ out.RawString("null") } else { out.RawByte('[') - for v155, v156 := range in.CanceledBy { - if v155 > 0 { + for v161, v162 := range in.CanceledBy { + if v161 > 0 { out.RawByte(',') } - out.Int64(int64(v156)) + out.Int64(int64(v162)) } out.RawByte(']') } @@ -5722,27 +6003,27 @@ func easyjson6601e8cdEncodeGithubComMeilisearchMeilisearchGo36(out *jwriter.Writ // MarshalJSON supports json.Marshaler interface func (v DeleteTasksQuery) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - easyjson6601e8cdEncodeGithubComMeilisearchMeilisearchGo36(&w, v) + easyjson6601e8cdEncodeGithubComMeilisearchMeilisearchGo38(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface func (v DeleteTasksQuery) MarshalEasyJSON(w *jwriter.Writer) { - easyjson6601e8cdEncodeGithubComMeilisearchMeilisearchGo36(w, v) + easyjson6601e8cdEncodeGithubComMeilisearchMeilisearchGo38(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *DeleteTasksQuery) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjson6601e8cdDecodeGithubComMeilisearchMeilisearchGo36(&r, v) + easyjson6601e8cdDecodeGithubComMeilisearchMeilisearchGo38(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface func (v *DeleteTasksQuery) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjson6601e8cdDecodeGithubComMeilisearchMeilisearchGo36(l, v) + easyjson6601e8cdDecodeGithubComMeilisearchMeilisearchGo38(l, v) } -func easyjson6601e8cdDecodeGithubComMeilisearchMeilisearchGo37(in *jlexer.Lexer, out *CsvDocumentsQuery) { +func easyjson6601e8cdDecodeGithubComMeilisearchMeilisearchGo39(in *jlexer.Lexer, out *CsvDocumentsQuery) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -5775,7 +6056,7 @@ func easyjson6601e8cdDecodeGithubComMeilisearchMeilisearchGo37(in *jlexer.Lexer, in.Consumed() } } -func easyjson6601e8cdEncodeGithubComMeilisearchMeilisearchGo37(out *jwriter.Writer, in CsvDocumentsQuery) { +func easyjson6601e8cdEncodeGithubComMeilisearchMeilisearchGo39(out *jwriter.Writer, in CsvDocumentsQuery) { out.RawByte('{') first := true _ = first @@ -5801,27 +6082,27 @@ func easyjson6601e8cdEncodeGithubComMeilisearchMeilisearchGo37(out *jwriter.Writ // MarshalJSON supports json.Marshaler interface func (v CsvDocumentsQuery) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - easyjson6601e8cdEncodeGithubComMeilisearchMeilisearchGo37(&w, v) + easyjson6601e8cdEncodeGithubComMeilisearchMeilisearchGo39(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface func (v CsvDocumentsQuery) MarshalEasyJSON(w *jwriter.Writer) { - easyjson6601e8cdEncodeGithubComMeilisearchMeilisearchGo37(w, v) + easyjson6601e8cdEncodeGithubComMeilisearchMeilisearchGo39(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *CsvDocumentsQuery) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjson6601e8cdDecodeGithubComMeilisearchMeilisearchGo37(&r, v) + easyjson6601e8cdDecodeGithubComMeilisearchMeilisearchGo39(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface func (v *CsvDocumentsQuery) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjson6601e8cdDecodeGithubComMeilisearchMeilisearchGo37(l, v) + easyjson6601e8cdDecodeGithubComMeilisearchMeilisearchGo39(l, v) } -func easyjson6601e8cdDecodeGithubComMeilisearchMeilisearchGo38(in *jlexer.Lexer, out *CreateIndexRequest) { +func easyjson6601e8cdDecodeGithubComMeilisearchMeilisearchGo40(in *jlexer.Lexer, out *CreateIndexRequest) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -5854,7 +6135,7 @@ func easyjson6601e8cdDecodeGithubComMeilisearchMeilisearchGo38(in *jlexer.Lexer, in.Consumed() } } -func easyjson6601e8cdEncodeGithubComMeilisearchMeilisearchGo38(out *jwriter.Writer, in CreateIndexRequest) { +func easyjson6601e8cdEncodeGithubComMeilisearchMeilisearchGo40(out *jwriter.Writer, in CreateIndexRequest) { out.RawByte('{') first := true _ = first @@ -5880,27 +6161,27 @@ func easyjson6601e8cdEncodeGithubComMeilisearchMeilisearchGo38(out *jwriter.Writ // MarshalJSON supports json.Marshaler interface func (v CreateIndexRequest) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - easyjson6601e8cdEncodeGithubComMeilisearchMeilisearchGo38(&w, v) + easyjson6601e8cdEncodeGithubComMeilisearchMeilisearchGo40(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface func (v CreateIndexRequest) MarshalEasyJSON(w *jwriter.Writer) { - easyjson6601e8cdEncodeGithubComMeilisearchMeilisearchGo38(w, v) + easyjson6601e8cdEncodeGithubComMeilisearchMeilisearchGo40(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *CreateIndexRequest) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjson6601e8cdDecodeGithubComMeilisearchMeilisearchGo38(&r, v) + easyjson6601e8cdDecodeGithubComMeilisearchMeilisearchGo40(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface func (v *CreateIndexRequest) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjson6601e8cdDecodeGithubComMeilisearchMeilisearchGo38(l, v) + easyjson6601e8cdDecodeGithubComMeilisearchMeilisearchGo40(l, v) } -func easyjson6601e8cdDecodeGithubComMeilisearchMeilisearchGo39(in *jlexer.Lexer, out *Client) { +func easyjson6601e8cdDecodeGithubComMeilisearchMeilisearchGo41(in *jlexer.Lexer, out *Client) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -5929,7 +6210,7 @@ func easyjson6601e8cdDecodeGithubComMeilisearchMeilisearchGo39(in *jlexer.Lexer, in.Consumed() } } -func easyjson6601e8cdEncodeGithubComMeilisearchMeilisearchGo39(out *jwriter.Writer, in Client) { +func easyjson6601e8cdEncodeGithubComMeilisearchMeilisearchGo41(out *jwriter.Writer, in Client) { out.RawByte('{') first := true _ = first @@ -5939,27 +6220,27 @@ func easyjson6601e8cdEncodeGithubComMeilisearchMeilisearchGo39(out *jwriter.Writ // MarshalJSON supports json.Marshaler interface func (v Client) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - easyjson6601e8cdEncodeGithubComMeilisearchMeilisearchGo39(&w, v) + easyjson6601e8cdEncodeGithubComMeilisearchMeilisearchGo41(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface func (v Client) MarshalEasyJSON(w *jwriter.Writer) { - easyjson6601e8cdEncodeGithubComMeilisearchMeilisearchGo39(w, v) + easyjson6601e8cdEncodeGithubComMeilisearchMeilisearchGo41(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *Client) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjson6601e8cdDecodeGithubComMeilisearchMeilisearchGo39(&r, v) + easyjson6601e8cdDecodeGithubComMeilisearchMeilisearchGo41(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface func (v *Client) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjson6601e8cdDecodeGithubComMeilisearchMeilisearchGo39(l, v) + easyjson6601e8cdDecodeGithubComMeilisearchMeilisearchGo41(l, v) } -func easyjson6601e8cdDecodeGithubComMeilisearchMeilisearchGo40(in *jlexer.Lexer, out *CancelTasksQuery) { +func easyjson6601e8cdDecodeGithubComMeilisearchMeilisearchGo42(in *jlexer.Lexer, out *CancelTasksQuery) { isTopLevel := in.IsStart() if in.IsNull() { if isTopLevel { @@ -5994,9 +6275,9 @@ func easyjson6601e8cdDecodeGithubComMeilisearchMeilisearchGo40(in *jlexer.Lexer, out.UIDS = (out.UIDS)[:0] } for !in.IsDelim(']') { - var v157 int64 - v157 = int64(in.Int64()) - out.UIDS = append(out.UIDS, v157) + var v163 int64 + v163 = int64(in.Int64()) + out.UIDS = append(out.UIDS, v163) in.WantComma() } in.Delim(']') @@ -6017,9 +6298,9 @@ func easyjson6601e8cdDecodeGithubComMeilisearchMeilisearchGo40(in *jlexer.Lexer, out.IndexUIDS = (out.IndexUIDS)[:0] } for !in.IsDelim(']') { - var v158 string - v158 = string(in.String()) - out.IndexUIDS = append(out.IndexUIDS, v158) + var v164 string + v164 = string(in.String()) + out.IndexUIDS = append(out.IndexUIDS, v164) in.WantComma() } in.Delim(']') @@ -6040,9 +6321,9 @@ func easyjson6601e8cdDecodeGithubComMeilisearchMeilisearchGo40(in *jlexer.Lexer, out.Statuses = (out.Statuses)[:0] } for !in.IsDelim(']') { - var v159 TaskStatus - v159 = TaskStatus(in.String()) - out.Statuses = append(out.Statuses, v159) + var v165 TaskStatus + v165 = TaskStatus(in.String()) + out.Statuses = append(out.Statuses, v165) in.WantComma() } in.Delim(']') @@ -6063,9 +6344,9 @@ func easyjson6601e8cdDecodeGithubComMeilisearchMeilisearchGo40(in *jlexer.Lexer, out.Types = (out.Types)[:0] } for !in.IsDelim(']') { - var v160 TaskType - v160 = TaskType(in.String()) - out.Types = append(out.Types, v160) + var v166 TaskType + v166 = TaskType(in.String()) + out.Types = append(out.Types, v166) in.WantComma() } in.Delim(']') @@ -6096,7 +6377,7 @@ func easyjson6601e8cdDecodeGithubComMeilisearchMeilisearchGo40(in *jlexer.Lexer, in.Consumed() } } -func easyjson6601e8cdEncodeGithubComMeilisearchMeilisearchGo40(out *jwriter.Writer, in CancelTasksQuery) { +func easyjson6601e8cdEncodeGithubComMeilisearchMeilisearchGo42(out *jwriter.Writer, in CancelTasksQuery) { out.RawByte('{') first := true _ = first @@ -6107,11 +6388,11 @@ func easyjson6601e8cdEncodeGithubComMeilisearchMeilisearchGo40(out *jwriter.Writ out.RawString("null") } else { out.RawByte('[') - for v161, v162 := range in.UIDS { - if v161 > 0 { + for v167, v168 := range in.UIDS { + if v167 > 0 { out.RawByte(',') } - out.Int64(int64(v162)) + out.Int64(int64(v168)) } out.RawByte(']') } @@ -6123,11 +6404,11 @@ func easyjson6601e8cdEncodeGithubComMeilisearchMeilisearchGo40(out *jwriter.Writ out.RawString("null") } else { out.RawByte('[') - for v163, v164 := range in.IndexUIDS { - if v163 > 0 { + for v169, v170 := range in.IndexUIDS { + if v169 > 0 { out.RawByte(',') } - out.String(string(v164)) + out.String(string(v170)) } out.RawByte(']') } @@ -6139,11 +6420,11 @@ func easyjson6601e8cdEncodeGithubComMeilisearchMeilisearchGo40(out *jwriter.Writ out.RawString("null") } else { out.RawByte('[') - for v165, v166 := range in.Statuses { - if v165 > 0 { + for v171, v172 := range in.Statuses { + if v171 > 0 { out.RawByte(',') } - out.String(string(v166)) + out.String(string(v172)) } out.RawByte(']') } @@ -6155,11 +6436,11 @@ func easyjson6601e8cdEncodeGithubComMeilisearchMeilisearchGo40(out *jwriter.Writ out.RawString("null") } else { out.RawByte('[') - for v167, v168 := range in.Types { - if v167 > 0 { + for v173, v174 := range in.Types { + if v173 > 0 { out.RawByte(',') } - out.String(string(v168)) + out.String(string(v174)) } out.RawByte(']') } @@ -6190,23 +6471,23 @@ func easyjson6601e8cdEncodeGithubComMeilisearchMeilisearchGo40(out *jwriter.Writ // MarshalJSON supports json.Marshaler interface func (v CancelTasksQuery) MarshalJSON() ([]byte, error) { w := jwriter.Writer{} - easyjson6601e8cdEncodeGithubComMeilisearchMeilisearchGo40(&w, v) + easyjson6601e8cdEncodeGithubComMeilisearchMeilisearchGo42(&w, v) return w.Buffer.BuildBytes(), w.Error } // MarshalEasyJSON supports easyjson.Marshaler interface func (v CancelTasksQuery) MarshalEasyJSON(w *jwriter.Writer) { - easyjson6601e8cdEncodeGithubComMeilisearchMeilisearchGo40(w, v) + easyjson6601e8cdEncodeGithubComMeilisearchMeilisearchGo42(w, v) } // UnmarshalJSON supports json.Unmarshaler interface func (v *CancelTasksQuery) UnmarshalJSON(data []byte) error { r := jlexer.Lexer{Data: data} - easyjson6601e8cdDecodeGithubComMeilisearchMeilisearchGo40(&r, v) + easyjson6601e8cdDecodeGithubComMeilisearchMeilisearchGo42(&r, v) return r.Error() } // UnmarshalEasyJSON supports easyjson.Unmarshaler interface func (v *CancelTasksQuery) UnmarshalEasyJSON(l *jlexer.Lexer) { - easyjson6601e8cdDecodeGithubComMeilisearchMeilisearchGo40(l, v) + easyjson6601e8cdDecodeGithubComMeilisearchMeilisearchGo42(l, v) } From 7a6746aef5e860557c06e2ef5eda04ca24b99631 Mon Sep 17 00:00:00 2001 From: Miguel Targa Date: Tue, 23 Jul 2024 22:31:21 -0400 Subject: [PATCH 3/7] Add code-samples --- .code-samples.meilisearch.yaml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.code-samples.meilisearch.yaml b/.code-samples.meilisearch.yaml index 4ce3549e..6c9af3e0 100644 --- a/.code-samples.meilisearch.yaml +++ b/.code-samples.meilisearch.yaml @@ -98,6 +98,17 @@ multi_search_1: |- }, }, }) +facet_search_1: |- + client.Index("movies").FacetSearch(&meilisearch.FacetSearchRequest{ + FacetQuery: "fiction", + FacetName: "genres", + Filter: "rating > 3", + }) +facet_search_3: |- + client.Index("movies").FacetSearch(&meilisearch.FacetSearchRequest{ + FacetQuery: "c", + FacetName: "genres", + }) delete_tasks_1: |- client.DeleteTaks(&meilisearch.DeleteTasksQuery{ UIDS: []int64{1, 2}, From ccf656ff7a8f2bb20cff3d51d0f5521852865f34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9mentine?= Date: Thu, 25 Jul 2024 14:39:24 +0200 Subject: [PATCH 4/7] Update .code-samples.meilisearch.yaml --- .code-samples.meilisearch.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.code-samples.meilisearch.yaml b/.code-samples.meilisearch.yaml index 6c9af3e0..d01f1f24 100644 --- a/.code-samples.meilisearch.yaml +++ b/.code-samples.meilisearch.yaml @@ -99,7 +99,7 @@ multi_search_1: |- }, }) facet_search_1: |- - client.Index("movies").FacetSearch(&meilisearch.FacetSearchRequest{ + client.Index("books").FacetSearch(&meilisearch.FacetSearchRequest{ FacetQuery: "fiction", FacetName: "genres", Filter: "rating > 3", From 4211e24c43535336b1f009be23cbbe170fb72daf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9mentine?= Date: Thu, 25 Jul 2024 14:39:28 +0200 Subject: [PATCH 5/7] Update .code-samples.meilisearch.yaml --- .code-samples.meilisearch.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.code-samples.meilisearch.yaml b/.code-samples.meilisearch.yaml index d01f1f24..9cf7ce6c 100644 --- a/.code-samples.meilisearch.yaml +++ b/.code-samples.meilisearch.yaml @@ -105,7 +105,7 @@ facet_search_1: |- Filter: "rating > 3", }) facet_search_3: |- - client.Index("movies").FacetSearch(&meilisearch.FacetSearchRequest{ + client.Index("books").FacetSearch(&meilisearch.FacetSearchRequest{ FacetQuery: "c", FacetName: "genres", }) From 8039c2f42b6495e6f4845dbe8749f59e460e46d8 Mon Sep 17 00:00:00 2001 From: Miguel Targa Date: Thu, 25 Jul 2024 21:24:05 -0400 Subject: [PATCH 6/7] Increase code coverage --- index_facet_search_test.go | 141 +++++++++++++++++++++++++++++++++++-- 1 file changed, 137 insertions(+), 4 deletions(-) diff --git a/index_facet_search_test.go b/index_facet_search_test.go index 6858a616..87dbf639 100644 --- a/index_facet_search_test.go +++ b/index_facet_search_test.go @@ -43,7 +43,138 @@ func TestIndex_FacetSearch(t *testing.T) { }, wantErr: false, }, + { + name: "TestIndexFacetSearchWithFilter", + args: args{ + UID: "indexUID", + client: defaultClient, + request: &FacetSearchRequest{ + FacetName: "tag", + FacetQuery: "Novel", + Filter: "tag = 'Novel'", + }, + filterableAttributes: []string{"tag"}, + }, + want: &FacetSearchResponse{ + FacetHits: []interface{}{ + map[string]interface{}{ + "value": "Novel", "count": float64(5), + }, + }, + FacetQuery: "Novel", + }, + wantErr: false, + }, + { + name: "TestIndexFacetSearchWithMatchingStrategy", + args: args{ + UID: "indexUID", + client: defaultClient, + request: &FacetSearchRequest{ + FacetName: "tag", + FacetQuery: "Novel", + MatchingStrategy: "frequency", + }, + filterableAttributes: []string{"tag"}, + }, + want: &FacetSearchResponse{ + FacetHits: []interface{}{ + map[string]interface{}{ + "value": "Novel", "count": float64(5), + }, + }, + FacetQuery: "Novel", + }, + wantErr: false, + }, + { + name: "TestIndexFacetSearchWithAttributesToSearchOn", + args: args{ + UID: "indexUID", + client: defaultClient, + request: &FacetSearchRequest{ + FacetName: "tag", + FacetQuery: "Novel", + AttributesToSearchOn: []string{"tag"}, + }, + filterableAttributes: []string{"tag"}, + }, + want: &FacetSearchResponse{ + FacetHits: []interface{}{ + map[string]interface{}{ + "value": "Novel", "count": float64(5), + }, + }, + FacetQuery: "Novel", + }, + wantErr: false, + }, + { + name: "TestIndexFacetSearchWithNoFacetSearchRequest", + args: args{ + UID: "indexUID", + client: defaultClient, + request: nil, + }, + want: nil, + wantErr: true, + }, + { + name: "TestIndexFacetSearchWithNoFacetName", + args: args{ + UID: "indexUID", + client: defaultClient, + request: &FacetSearchRequest{ + FacetQuery: "Novel", + }, + }, + want: nil, + wantErr: true, + }, + { + name: "TestIndexFacetSearchWithNoFacetQuery", + args: args{ + UID: "indexUID", + client: defaultClient, + request: &FacetSearchRequest{ + FacetName: "tag", + }, + }, + want: nil, + wantErr: true, + }, + { + name: "TestIndexFacetSearchWithNoFilterableAttributes", + args: args{ + UID: "indexUID", + client: defaultClient, + request: &FacetSearchRequest{ + FacetName: "tag", + FacetQuery: "Novel", + }, + }, + want: nil, + wantErr: true, + }, + { + name: "TestIndexFacetSearchWithQ", + args: args{ + UID: "indexUID", + client: defaultClient, + request: &FacetSearchRequest{ + Q: "query", + FacetName: "tag", + }, + filterableAttributes: []string{"tag"}, + }, + want: &FacetSearchResponse{ + FacetHits: []interface{}{}, + FacetQuery: "", + }, + wantErr: false, + }, } + for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { SetUpIndexForFaceting() @@ -51,15 +182,17 @@ func TestIndex_FacetSearch(t *testing.T) { i := c.Index(tt.args.UID) t.Cleanup(cleanup(c)) - updateFilter, err := i.UpdateFilterableAttributes(&tt.args.filterableAttributes) - require.NoError(t, err) - testWaitForTask(t, i, updateFilter) + if len(tt.args.filterableAttributes) > 0 { + updateFilter, err := i.UpdateFilterableAttributes(&tt.args.filterableAttributes) + require.NoError(t, err) + testWaitForTask(t, i, updateFilter) + } gotRaw, err := i.FacetSearch(tt.args.request) if tt.wantErr { require.Error(t, err) - require.Nil(t, tt.want) + require.Nil(t, gotRaw) return } From c4e85d67aceb545a9d2610fde6c6eea1e8b04ffc Mon Sep 17 00:00:00 2001 From: Miguel Targa Date: Fri, 26 Jul 2024 09:15:24 -0400 Subject: [PATCH 7/7] fix linting --- .code-samples.meilisearch.yaml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.code-samples.meilisearch.yaml b/.code-samples.meilisearch.yaml index 9cf7ce6c..59ec19b7 100644 --- a/.code-samples.meilisearch.yaml +++ b/.code-samples.meilisearch.yaml @@ -102,7 +102,7 @@ facet_search_1: |- client.Index("books").FacetSearch(&meilisearch.FacetSearchRequest{ FacetQuery: "fiction", FacetName: "genres", - Filter: "rating > 3", + Filter: "rating > 3", }) facet_search_3: |- client.Index("books").FacetSearch(&meilisearch.FacetSearchRequest{ @@ -656,7 +656,11 @@ getting_started_configure_settings: |- getting_started_faceting: |- client.Index("movies").UpdateFaceting(&meilisearch.Faceting{ MaxValuesPerFacet: 2, + SortFacetValuesBy: { + "*": "count" + } }) + getting_started_pagination: |- client.Index("movies").UpdatePagination(&meilisearch.Pagination{ MaxTotalHits: 500,