be careful when reading elastic response

This commit is contained in:
Cyberes 2024-02-12 16:56:52 -07:00
parent b8c30e87d7
commit 8c76455b60
1 changed files with 7 additions and 3 deletions

View File

@ -46,11 +46,15 @@ func getPathsFromIndex() (map[string]string, map[string]string, error) {
}
for {
scrollID := r["_scroll_id"].(string)
hits := r["hits"].(map[string]interface{})["hits"].([]interface{})
scrollID, ok := r["_scroll_id"].(string)
if !ok {
// No more pages to scroll through
break
}
// Break after no more documents
hits := r["hits"].(map[string]interface{})["hits"].([]interface{})
if len(hits) == 0 {
// Break after no more documents
break
}