Skip to content
Snippets Groups Projects
Commit f41e4cfe authored by Francé Wilke's avatar Francé Wilke
Browse files

Api-logs return if response is empty

parent 5d4348b9
No related branches found
No related tags found
No related merge requests found
......@@ -34,10 +34,10 @@ type MappingKeyword struct {
}
type SearchRequestBody struct {
Size int64 `json:"size,omitempty"`
Sort []map[string]string `json:"sort,omitempty"` // order and order_by
Size int64 `json:"size,omitempty"` // limit
From int64 `json:"from,omitempty"` // offset
Query Query `json:"query"`
Sort []map[string]string `json:"sort,omitempty"`
From int64 `json:"from,omitempty"`
}
type Query struct {
......
......@@ -398,7 +398,7 @@ type IndexSettings struct {
//Search
//Return:
// docs will be a slice of the TimeSeries data type
func (ts *timeSeries) Search(query Query, sortQuery []map[string]string, limit int64, offset int64) (docs map[string]interface{}, totalCount int, err error) {
func (ts *timeSeries) Search(query Query, sort []map[string]string, limit int64, offset int64) (docs map[string]interface{}, totalCount int, err error) {
if ts == nil {
return nil, 0, errors.Errorf("time series == nil")
}
......@@ -418,10 +418,10 @@ func (ts *timeSeries) Search(query Query, sortQuery []map[string]string, limit i
// }
// }
body := SearchRequestBody{
Sort: sort,
Size: limit,
Query: query,
Sort: sortQuery,
From: offset,
Query: query,
}
jsonBody, _ := json.Marshal(body)
......@@ -471,6 +471,9 @@ func (ts *timeSeries) Search(query Query, sortQuery []map[string]string, limit i
}
docs = map[string]interface{}{}
if !hits.IsValid() {
return
}
for i := 0; i < hits.Len(); i++ {
hit := hits.Index(i)
index := hit.Field(0).Interface().(string) // HitDoc.Index
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment