diff --git a/src/OpenSearchServer/Response/Result.php b/src/OpenSearchServer/Response/Result.php index 933b45f..44aeed5 100644 --- a/src/OpenSearchServer/Response/Result.php +++ b/src/OpenSearchServer/Response/Result.php @@ -63,8 +63,10 @@ public function getCollapsedCount() { * Default value: true. */ public function getField($fieldName, $returnFirstValueOnly = true) { - if(!empty($this->fields[$fieldName]) && count($this->fields[$fieldName] > 0)) { - return ($returnFirstValueOnly) ? $this->fields[$fieldName][0] : $this->fields[$fieldName]; + if(!empty($this->fields[$fieldName]) ) { + if (is_array($this->fields[$fieldName]) && count($this->fields[$fieldName]) > 0) { + return ($returnFirstValueOnly) ? $this->fields[$fieldName][0] : $this->fields[$fieldName]; + } } } @@ -76,8 +78,10 @@ public function getField($fieldName, $returnFirstValueOnly = true) { * Default value: true. */ public function getSnippet($fieldName, $returnFirstValueOnly = true) { - if(!empty($this->snippets[$fieldName]) && count($this->snippets[$fieldName] > 0)) { - return ($returnFirstValueOnly) ? $this->snippets[$fieldName][0] : $this->snippets[$fieldName]; + if(!empty($this->snippets[$fieldName]) && is_array($this->snippets[$fieldName])) { + if (count($this->snippets[$fieldName]) > 0) { + return ($returnFirstValueOnly) ? $this->snippets[$fieldName][0] : $this->snippets[$fieldName]; + } } } @@ -112,4 +116,4 @@ public function getHighlightedSnippets() { public function isHighlightedSnippets($fieldname) { return in_array($fieldname, $this->highlightedSnippets); } -} \ No newline at end of file +}