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

Feat support proximityPrecision setting #564

Merged
merged 1 commit into from
Aug 21, 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
6 changes: 6 additions & 0 deletions .code-samples.meilisearch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -924,3 +924,9 @@ update_non_separator_tokens_1: |-
})
reset_non_separator_tokens_1: |-
client.Index("articles").ResetNonSeparatorTokens()
get_proximity_precision_settings_1: |-
client.Index("books").GetProximityPrecision()
update_proximity_precision_settings_1: |-
client.Index("books").UpdateProximityPrecision(ByAttribute)
reset_proximity_precision_settings_1: |-
client.Index("books").ResetProximityPrecision()
24 changes: 24 additions & 0 deletions index.go
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,30 @@ type IndexManager interface {
// https://www.meilisearch.com/docs/reference/api/settings#reset-dictionary
ResetDictionaryWithContext(ctx context.Context) (*TaskInfo, error)

// GetProximityPrecision returns ProximityPrecision configuration value
// https://www.meilisearch.com/docs/reference/api/settings#get-proximity-precision-settings
GetProximityPrecision() (ProximityPrecisionType, error)

// GetProximityPrecisionWithContext returns ProximityPrecision configuration value and support parent context
// https://www.meilisearch.com/docs/reference/api/settings#get-proximity-precision-settings
GetProximityPrecisionWithContext(ctx context.Context) (ProximityPrecisionType, error)

// UpdateProximityPrecision set ProximityPrecision value ByWord or ByAttribute
// https://www.meilisearch.com/docs/reference/api/settings#update-proximity-precision-settings
UpdateProximityPrecision(proximityType ProximityPrecisionType) (*TaskInfo, error)

// UpdateProximityPrecisionWithContext set ProximityPrecision value ByWord or ByAttribute and support parent context
// https://www.meilisearch.com/docs/reference/api/settings#update-proximity-precision-settings
UpdateProximityPrecisionWithContext(ctx context.Context, proximityType ProximityPrecisionType) (*TaskInfo, error)

// ResetProximityPrecision reset ProximityPrecision to default ByWord
// https://www.meilisearch.com/docs/reference/api/settings#reset-proximity-precision-settings
ResetProximityPrecision() (*TaskInfo, error)

// ResetProximityPrecisionWithContext reset ProximityPrecision to default ByWord and support parent context
// https://www.meilisearch.com/docs/reference/api/settings#reset-proximity-precision-settings
ResetProximityPrecisionWithContext(ctx context.Context) (*TaskInfo, error)

// WaitForTask waits for a task to complete by its UID with the given interval.
WaitForTask(taskUID int64, interval time.Duration) (*Task, error)

Expand Down
61 changes: 61 additions & 0 deletions index_settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -1041,3 +1041,64 @@
}
return resp, nil
}

func (i *index) GetProximityPrecision() (ProximityPrecisionType, error) {
return i.GetProximityPrecisionWithContext(context.Background())
}

func (i *index) GetProximityPrecisionWithContext(ctx context.Context) (ProximityPrecisionType, error) {
resp := new(ProximityPrecisionType)
req := &internalRequest{
endpoint: "/indexes/" + i.uid + "/settings/proximity-precision",
method: http.MethodGet,
withRequest: nil,
withResponse: resp,
acceptedStatusCodes: []int{http.StatusOK},
functionName: "GetProximityPrecision",
}
if err := i.client.executeRequest(ctx, req); err != nil {
return "", err

Check warning on line 1060 in index_settings.go

View check run for this annotation

Codecov / codecov/patch

index_settings.go#L1060

Added line #L1060 was not covered by tests
}
return *resp, nil
}

func (i *index) UpdateProximityPrecision(proximityType ProximityPrecisionType) (*TaskInfo, error) {
return i.UpdateProximityPrecisionWithContext(context.Background(), proximityType)
}

func (i *index) UpdateProximityPrecisionWithContext(ctx context.Context, proximityType ProximityPrecisionType) (*TaskInfo, error) {
resp := new(TaskInfo)
req := &internalRequest{
endpoint: "/indexes/" + i.uid + "/settings/proximity-precision",
method: http.MethodPut,
withRequest: &proximityType,
withResponse: resp,
contentType: contentTypeJSON,
acceptedStatusCodes: []int{http.StatusAccepted},
functionName: "UpdateProximityPrecision",
}
if err := i.client.executeRequest(ctx, req); err != nil {
return nil, err

Check warning on line 1081 in index_settings.go

View check run for this annotation

Codecov / codecov/patch

index_settings.go#L1081

Added line #L1081 was not covered by tests
}
return resp, nil
}

func (i *index) ResetProximityPrecision() (*TaskInfo, error) {
return i.ResetProximityPrecisionWithContext(context.Background())
}

func (i *index) ResetProximityPrecisionWithContext(ctx context.Context) (*TaskInfo, error) {
resp := new(TaskInfo)
req := &internalRequest{
endpoint: "/indexes/" + i.uid + "/settings/proximity-precision",
method: http.MethodDelete,
withRequest: nil,
withResponse: resp,
acceptedStatusCodes: []int{http.StatusAccepted},
functionName: "ResetProximityPrecision",
}
if err := i.client.executeRequest(ctx, req); err != nil {
return nil, err

Check warning on line 1101 in index_settings.go

View check run for this annotation

Codecov / codecov/patch

index_settings.go#L1101

Added line #L1101 was not covered by tests
}
return resp, nil
}
Loading
Loading