Skip to content

Commit

Permalink
Add faceting settings
Browse files Browse the repository at this point in the history
  • Loading branch information
GoryMoon committed Jul 25, 2022
1 parent 9236b8f commit b7fddab
Show file tree
Hide file tree
Showing 6 changed files with 468 additions and 42 deletions.
15 changes: 15 additions & 0 deletions .code-samples.meilisearch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ update_settings_1: |-
},
DisableOnAttributes: []string{"title"},
},
Faceting: &meilisearch.Faceting{
MaxValuesPerFacet: 200
},
}
client.Index("movies").UpdateSettings(&settings)
reset_settings_1: |-
Expand Down Expand Up @@ -233,6 +236,14 @@ update_typo_tolerance_1: |-
})
reset_typo_tolerance_1: |-
client.Index("books").ResetTypoTolerance()
get_faceting_settings_1:
client.Index("books").GetFaceting()
update_faceting_settings_1: |-
client.Index("books").UpdateFaceting(&meilisearch.Faceting{
MaxValuesPerFacet: 2,
})
reset_faceting_settings_1: |-
client.Index("books").ResetFaceting()
get_index_stats_1: |-
client.Index("movies").GetStats()
get_indexes_stats_1: |-
Expand Down Expand Up @@ -372,6 +383,10 @@ settings_guide_sortable_1: |-
},
}
client.Index("books").UpdateSettings(&settings)
settings_guide_faceting_1: |-
client.Index("movies").UpdateFaceting(&meilisearch.Faceting{
MaxValuesPerFacet: 5
})
settings_guide_typo_tolerance_1: |-
client.index("movies").UpdateTypoTolerance({
MinWordSizeForTypos: meilisearch.MinWordSizeForTypo{
Expand Down
49 changes: 49 additions & 0 deletions index_settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -543,3 +543,52 @@ func (i Index) ResetPagination() (resp *TaskInfo, err error) {
}
return resp, nil
}

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

func (i Index) UpdateFaceting(request *Faceting) (resp *TaskInfo, err error) {
resp = &TaskInfo{}
req := internalRequest{
endpoint: "/indexes/" + i.UID + "/settings/faceting",
method: http.MethodPatch,
contentType: contentTypeJSON,
withRequest: &request,
withResponse: resp,
acceptedStatusCodes: []int{http.StatusAccepted},
functionName: "UpdateFaceting",
}
if err := i.client.executeRequest(req); err != nil {
return nil, err
}
return resp, nil
}

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

0 comments on commit b7fddab

Please sign in to comment.