Skip to content

Commit

Permalink
Merge pull request #294 from meilisearch/typo-tolerance
Browse files Browse the repository at this point in the history
Add typo tolerance settings
  • Loading branch information
alallema authored May 4, 2022
2 parents 25fbcdf + c2575b2 commit 85c5c4c
Show file tree
Hide file tree
Showing 6 changed files with 1,025 additions and 335 deletions.
12 changes: 6 additions & 6 deletions index_search_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1032,7 +1032,7 @@ func TestIndex_SearchOnNestedFileds(t *testing.T) {
map[string]interface{}{
"id": float64(5), "title": "The Hobbit",
"info": map[string]interface{}{
"comment": "An awesome book",
"comment": "An awesome book",
"reviewNb": float64(900),
},
},
Expand All @@ -1056,7 +1056,7 @@ func TestIndex_SearchOnNestedFileds(t *testing.T) {
map[string]interface{}{
"id": float64(5), "title": "The Hobbit",
"info": map[string]interface{}{
"comment": "An awesome book",
"comment": "An awesome book",
"reviewNb": float64(900),
},
},
Expand All @@ -1080,14 +1080,14 @@ func TestIndex_SearchOnNestedFileds(t *testing.T) {
map[string]interface{}{
"id": float64(2), "title": "Le Petit Prince",
"info": map[string]interface{}{
"comment": "A french book",
"comment": "A french book",
"reviewNb": float64(600),
},
},
map[string]interface{}{
"id": float64(3), "title": "Le Rouge et le Noir",
"info": map[string]interface{}{
"comment": "Another french book",
"comment": "Another french book",
"reviewNb": float64(700),
},
},
Expand All @@ -1114,7 +1114,7 @@ func TestIndex_SearchOnNestedFileds(t *testing.T) {
map[string]interface{}{
"id": float64(5), "title": "The Hobbit",
"info": map[string]interface{}{
"comment": "An awesome book",
"comment": "An awesome book",
"reviewNb": float64(900),
},
},
Expand Down Expand Up @@ -1148,7 +1148,7 @@ func TestIndex_SearchOnNestedFileds(t *testing.T) {
map[string]interface{}{
"id": float64(5), "title": "The Hobbit",
"info": map[string]interface{}{
"comment": "An awesome book",
"comment": "An awesome book",
"reviewNb": float64(900),
},
},
Expand Down
49 changes: 49 additions & 0 deletions index_settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -445,3 +445,52 @@ func (i Index) ResetSortableAttributes() (resp *Task, err error) {
}
return resp, nil
}

func (i Index) GetTypoTolerance() (resp *TypoTolerance, err error) {
resp = &TypoTolerance{}
req := internalRequest{
endpoint: "/indexes/" + i.UID + "/settings/typo-tolerance",
method: http.MethodGet,
withRequest: nil,
withResponse: resp,
acceptedStatusCodes: []int{http.StatusOK},
functionName: "GetTypoTolerance",
}
if err := i.client.executeRequest(req); err != nil {
return nil, err
}
return resp, nil
}

func (i Index) UpdateTypoTolerance(request *TypoTolerance) (resp *Task, err error) {
resp = &Task{}
req := internalRequest{
endpoint: "/indexes/" + i.UID + "/settings/typo-tolerance",
method: http.MethodPost,
contentType: contentTypeJSON,
withRequest: &request,
withResponse: resp,
acceptedStatusCodes: []int{http.StatusAccepted},
functionName: "UpdateTypoTolerance",
}
if err := i.client.executeRequest(req); err != nil {
return nil, err
}
return resp, nil
}

func (i Index) ResetTypoTolerance() (resp *Task, err error) {
resp = &Task{}
req := internalRequest{
endpoint: "/indexes/" + i.UID + "/settings/typo-tolerance",
method: http.MethodDelete,
withRequest: nil,
withResponse: resp,
acceptedStatusCodes: []int{http.StatusAccepted},
functionName: "ResetTypoTolerance",
}
if err := i.client.executeRequest(req); err != nil {
return nil, err
}
return resp, nil
}
Loading

0 comments on commit 85c5c4c

Please sign in to comment.