Skip to content

Commit e76d3a2

Browse files
committed
Keyword sanitize on aggs & base migration
1 parent b845697 commit e76d3a2

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

src/DSL/Bridge.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -842,9 +842,15 @@ private function processBuckets($columns, $keys, $response, $index, $includeDocC
842842
if (!empty($response[$keys[$index]]['buckets'])) {
843843
foreach ($response[$keys[$index]]['buckets'] as $res) {
844844
$datum = $currentData;
845-
$datum[$columns[$index]] = $res['key'];
845+
//clear keyword from column name
846+
$col = $columns[$index];
847+
if (str_contains($col, '.keyword')) {
848+
$col = str_replace('.keyword', '', $col);
849+
}
850+
851+
$datum[$col] = $res['key'];
846852
if ($includeDocCount) {
847-
$datum[$columns[$index].'_count'] = $res['doc_count'];
853+
$datum[$col.'_count'] = $res['doc_count'];
848854
}
849855

850856
if (isset($columns[$index + 1])) {

src/Schema/IndexBlueprint.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,12 +173,12 @@ public function buildIndexModify(Connection $connection)
173173

174174
public function increments($column)
175175
{
176-
return $this->addField('text', $column);
176+
return $this->addField('keyword', $column);
177177
}
178178

179179
public function string($column)
180180
{
181-
return $this->addField('text', $column);
181+
return $this->addField('keyword', $column);
182182
}
183183

184184

0 commit comments

Comments
 (0)