PHRAS-2785 #comment Port41 of PHRAS-2758 #time 1h

This commit is contained in:
Harrys Ravalomanana
2019-10-08 16:40:07 +04:00
parent d6c61eba28
commit ce67d5f62d

View File

@@ -46,22 +46,23 @@ class FacetsResponse
if (!isset($bucket['key']) || !isset($bucket['doc_count'])) { if (!isset($bucket['key']) || !isset($bucket['doc_count'])) {
$this->throwAggregationResponseError(); $this->throwAggregationResponseError();
} }
$key = array_key_exists('key_as_string', $bucket) ? $bucket['key_as_string'] : $bucket['key'];
if($tf) { if($tf) {
// the field is one of the hardcoded tech fields // the field is one of the hardcoded tech fields
$value = [ $value = [
'value' => $valueFormatter($bucket['key']), 'value' => $valueFormatter($key),
'raw_value' => $bucket['key'], 'raw_value' => $key,
'count' => $bucket['doc_count'], 'count' => $bucket['doc_count'],
'query' => sprintf($tf['query'], $this->escaper->escapeWord($bucket['key'])) 'query' => sprintf($tf['query'], $this->escaper->escapeWord($key))
]; ];
} }
else { else {
// the field is a normal field // the field is a normal field
$value = [ $value = [
'value' => $bucket['key'], 'value' => $key,
'raw_value' => $bucket['key'], 'raw_value' => $key,
'count' => $bucket['doc_count'], 'count' => $bucket['doc_count'],
'query' => sprintf('field.%s:%s', $this->escaper->escapeWord($name), $this->escaper->escapeWord($bucket['key'])) 'query' => sprintf('field.%s:%s', $this->escaper->escapeWord($name), $this->escaper->escapeWord($key))
]; ];
} }