Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix allow typo tolerance to be disabled for an index #545

Merged
merged 1 commit into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 23 additions & 5 deletions index_settings_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2696,6 +2696,28 @@ func TestIndex_UpdateTypoTolerance(t *testing.T) {
},
wantResp: &defaultTypoTolerance,
},
{
name: "TestIndexDisableTypoTolerance",
args: args{
UID: "indexUID",
client: defaultClient,
request: TypoTolerance{
Enabled: false,
MinWordSizeForTypos: MinWordSizeForTypos{
OneTypo: 5,
TwoTypos: 9,
},
DisableOnWords: []string{},
DisableOnAttributes: []string{},
},
},
wantTask: &TaskInfo{
TaskUID: 1,
},
wantResp: &TypoTolerance{
Enabled: false,
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand All @@ -2704,16 +2726,12 @@ func TestIndex_UpdateTypoTolerance(t *testing.T) {
i := c.Index(tt.args.UID)
t.Cleanup(cleanup(c))

gotResp, err := i.GetTypoTolerance()
require.NoError(t, err)
require.Equal(t, tt.wantResp, gotResp)

gotTask, err := i.UpdateTypoTolerance(&tt.args.request)
require.NoError(t, err)
require.GreaterOrEqual(t, gotTask.TaskUID, tt.wantTask.TaskUID)
testWaitForTask(t, i, gotTask)

gotResp, err = i.GetTypoTolerance()
gotResp, err := i.GetTypoTolerance()
require.NoError(t, err)
require.Equal(t, &tt.args.request, gotResp)
})
Expand Down
2 changes: 1 addition & 1 deletion types.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ type Settings struct {

// TypoTolerance is the type that represents the typo tolerance setting in Meilisearch
type TypoTolerance struct {
Enabled bool `json:"enabled,omitempty"`
Enabled bool `json:"enabled"`
MinWordSizeForTypos MinWordSizeForTypos `json:"minWordSizeForTypos,omitempty"`
DisableOnWords []string `json:"disableOnWords,omitempty"`
DisableOnAttributes []string `json:"disableOnAttributes,omitempty"`
Expand Down
24 changes: 4 additions & 20 deletions types_easyjson.go

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

Loading