Skip to content

Commit 7708e43

Browse files
committed
Updating results to catch missing indices
1 parent 70121f2 commit 7708e43

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

Source/Core/Functions/Results.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,7 @@ public class Results {
302302

303303
if let json = JsonTools.serialiseJson(input) {
304304

305+
// Check for standard Elasticsearch error format
305306
if let errorMessage = json["error"] as? [String: Any] {
306307

307308
if let errorItems = errorMessage["root_cause"] as? [[String: Any]] {
@@ -313,6 +314,16 @@ public class Results {
313314
}
314315
}
315316

317+
// Return early if there's an error to prevent processing error response fields
318+
return result
319+
}
320+
321+
// Check for alternative error format with "message" and "ok" fields
322+
if let message = json["message"] as? String,
323+
let ok = json["ok"] as? Bool,
324+
ok == false {
325+
result.error = message
326+
return result
316327
}
317328

318329
for item in json {

0 commit comments

Comments
 (0)