Skip to content

Commit dbadc21

Browse files
committed
Merge pull request #24 from dmyers/patch-1
Fixes for parameter decoding and encoding with elasticsearch driver.
2 parents a66021f + bbbad80 commit dbadc21

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/Mmanos/Search/Index/Elasticsearch.php

+5-3
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ public function runQuery($query, array $options = array())
167167
array(
168168
'id' => array_get($response, '_id'),
169169
),
170-
json_decode(base64_decode(array_get($response, '_source._parameters', array())), true)
170+
json_decode(base64_decode(array_get($response, '_source._parameters', '')), true)
171171
));
172172
}
173173

@@ -187,7 +187,7 @@ public function runQuery($query, array $options = array())
187187
'id' => array_get($hit, '_id'),
188188
'_score' => array_get($hit, '_score'),
189189
),
190-
json_decode(base64_decode(array_get($hit, '_source._parameters', array())), true)
190+
json_decode(base64_decode(array_get($hit, '_source._parameters', '')), true)
191191
);
192192
}
193193
}
@@ -233,7 +233,9 @@ public function insert($id, array $fields, array $parameters = array())
233233
$this->delete($id);
234234
} catch (\Elasticsearch\Common\Exceptions\Missing404Exception $e) {}
235235

236-
$fields['_parameters'] = base64_encode(json_encode($parameters));
236+
if (!empty($parameters)) {
237+
$fields['_parameters'] = base64_encode(json_encode($parameters));
238+
}
237239

238240
$this->getClient()->index(array(
239241
'index' => $this->name,

0 commit comments

Comments
 (0)