58 lines
1.0 KiB
Go
58 lines
1.0 KiB
Go
|
package meilisearch
|
||
|
|
||
|
import "errors"
|
||
|
|
||
|
// Config ...
|
||
|
type Config struct {
|
||
|
URL string
|
||
|
APIKey string
|
||
|
}
|
||
|
|
||
|
func (c Config) Validate() error {
|
||
|
if c.URL == "" {
|
||
|
return errors.New("connect URL is required")
|
||
|
}
|
||
|
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
// IndexSettings ...
|
||
|
// More options at https://docs.meilisearch.com/reference/api/settings.html#update-settings
|
||
|
type IndexSettings struct {
|
||
|
SearchableAttributes []string
|
||
|
FilterableAttributes []string
|
||
|
SortableAttributes []string
|
||
|
}
|
||
|
|
||
|
// SearchPayload currently support only few of options
|
||
|
// More options at https://docs.meilisearch.com/reference/api/search.html#search-parameters
|
||
|
type SearchPayload struct {
|
||
|
// Main query
|
||
|
Query string
|
||
|
|
||
|
// Filter data after search
|
||
|
//
|
||
|
// [][]string{
|
||
|
// []string{"age > 18", "gender = female"},
|
||
|
// []string{"director = \"Nam HQ\""},
|
||
|
// }
|
||
|
Filter [][]string
|
||
|
|
||
|
// Limit and offset
|
||
|
//
|
||
|
// Default:
|
||
|
// - Offset: 0
|
||
|
// - Limit: 20
|
||
|
Pagination SearchPagination
|
||
|
|
||
|
// Sort data
|
||
|
//
|
||
|
// []string{ "field_a:asc", "field_b:desc" }
|
||
|
Sort []string
|
||
|
}
|
||
|
|
||
|
type SearchPagination struct {
|
||
|
Limit int64
|
||
|
Offset int64
|
||
|
}
|