-
Notifications
You must be signed in to change notification settings - Fork 0
/
search.go
28 lines (24 loc) · 990 Bytes
/
search.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package quickwitgosdk
type SearchRequest struct {
Query string `json:"query"`
SearchFields []string `json:"search_field,omitempty"`
StartTimestamp int64 `json:"start_timestamp,omitempty"`
EndTimestamp int64 `json:"end_timestamp,omitempty"`
MaxHits uint64 `json:"max_hits,omitempty"`
StartOffset uint64 `json:"start_offset,omitempty"`
SortByField string `json:"sort_by_field,omitempty"`
}
type SearchResponse struct {
NumHits uint64 `json:"num_hits"`
Hits []interface{} `json:"hits"`
ElapsedTimeMicros uint64 `json:"elapsed_time_micros"`
Aggregations interface{} `json:"aggregations,omitempty"`
}
func (c *Client) Search(indexId string, searchRequest SearchRequest) (searchResponse SearchResponse, err error) {
_, err = c.client.R().
SetPathParam("indexId", indexId).
SetBody(searchRequest).
SetResult(&searchResponse).
Post("/api/v1/{indexId}/search")
return searchResponse, err
}