github.com/qri-io/qri@v0.10.1-0.20220104210721-c771715036cb/registry/regclient/search.go (about) 1 package regclient 2 3 import ( 4 "context" 5 6 "github.com/qri-io/qri/registry" 7 ) 8 9 // SearchFilter stores various types of filters that may be applied 10 // to a search 11 type SearchFilter struct { 12 // Type denotes the ype of search filter 13 Type string 14 // Relation indicates the relation between the key and value 15 // supported options include ["eq"|"neq"|"gt"|"gte"|"lt"|"lte"] 16 Relation string 17 // Key corresponds to the name of the index mapping that we wish to 18 // apply the filter to 19 Key string 20 // Value is the predicate of the subject-relation-predicate triple 21 // eg. [key=timestamp] [gte] [value=[today]] 22 Value interface{} 23 } 24 25 // SearchParams contains the parameters that are passed to a 26 // Client.Search method 27 type SearchParams struct { 28 Query string 29 Filters []SearchFilter 30 Limit int 31 Offset int 32 } 33 34 // Search makes a registry search request 35 func (c Client) Search(ctx context.Context, p *SearchParams) ([]registry.SearchResult, error) { 36 if c.httpClient == nil { 37 return nil, ErrNoRegistry 38 } 39 40 params := ®istry.SearchParams{ 41 Q: p.Query, 42 //Filters: p.Filters, 43 Limit: p.Limit, 44 Offset: p.Offset, 45 } 46 res := []registry.SearchResult{} 47 err := c.httpClient.CallMethod(ctx, "/registry/search", "GET", "", params, &res) 48 if err != nil { 49 return nil, err 50 } 51 return res, nil 52 }