You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Each is a utility function to iterate over all hits. It saves you from
// checking for nil values. Notice that Each will ignore errors in
// serializing JSON and hits with empty/nil _source will get an empty
// value
func (r *SearchResult) Each(typ reflect.Type) []interface{} {
if r.Hits == nil || r.Hits.Hits == nil || len(r.Hits.Hits) == 0 {
return nil
}
slice := make([]interface{}, 0, len(r.Hits.Hits))
for _, hit := range r.Hits.Hits {
v := reflect.New(typ).Elem()
if hit.Source == nil {
slice = append(slice, v.Interface())
continue
}
//if json.Unmarshal err,no err message,no data and Not easy to find
//if json.Unmarshal err,no err message,no data and Not easy to find
//if json.Unmarshal err,no err message,no data and Not easy to find
//if json.Unmarshal err,no err message,no data and Not easy to find
//if json.Unmarshal err,no err message,no data and Not easy to find
//if json.Unmarshal err,no err message,no data and Not easy to find
if err := json.Unmarshal(hit.Source, v.Addr().Interface()); err == nil {
slice = append(slice, v.Interface())
}
}
return slice
}
The text was updated successfully, but these errors were encountered:
// Each is a utility function to iterate over all hits. It saves you from
// checking for nil values. Notice that Each will ignore errors in
// serializing JSON and hits with empty/nil _source will get an empty
// value
func (r *SearchResult) Each(typ reflect.Type) []interface{} {
if r.Hits == nil || r.Hits.Hits == nil || len(r.Hits.Hits) == 0 {
return nil
}
slice := make([]interface{}, 0, len(r.Hits.Hits))
for _, hit := range r.Hits.Hits {
v := reflect.New(typ).Elem()
if hit.Source == nil {
slice = append(slice, v.Interface())
continue
}
//if json.Unmarshal err,no err message,no data and Not easy to find
//if json.Unmarshal err,no err message,no data and Not easy to find
//if json.Unmarshal err,no err message,no data and Not easy to find
//if json.Unmarshal err,no err message,no data and Not easy to find
//if json.Unmarshal err,no err message,no data and Not easy to find
//if json.Unmarshal err,no err message,no data and Not easy to find
if err := json.Unmarshal(hit.Source, v.Addr().Interface()); err == nil {
slice = append(slice, v.Interface())
}
}
return slice
}
The text was updated successfully, but these errors were encountered: