Skip to content

Commit de0af85

Browse files
committed
Keyword sanitize on aggs & base migration
1 parent 01e3121 commit de0af85

File tree

3 files changed

+32
-2
lines changed

3 files changed

+32
-2
lines changed

src/DSL/Bridge.php

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

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

src/Schema/Builder.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,15 @@ private function _sanitizeFlatFields($flatFields)
269269
return $fields;
270270
}
271271

272+
//----------------------------------------------------------------------
273+
// Internal Laravel init migration catchers
274+
// *Case for when ES is the only datasource
275+
//----------------------------------------------------------------------
276+
public function hasTable($table)
277+
{
278+
return $this->getIndex($table);
279+
}
280+
272281

273282
//----------------------------------------------------------------------
274283
// Builders

src/Schema/IndexBlueprint.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,21 @@ public function buildIndexModify(Connection $connection)
165165
}
166166
}
167167

168+
//----------------------------------------------------------------------
169+
// Internal Laravel init migration catchers
170+
// *Case for when ES is the only datasource
171+
//----------------------------------------------------------------------
172+
173+
public function increments($column)
174+
{
175+
return $this->addField('keyword', $column);
176+
}
177+
178+
public function string($column)
179+
{
180+
return $this->addField('keyword', $column);
181+
}
182+
168183
//----------------------------------------------------------------------
169184
// Helpers
170185
//----------------------------------------------------------------------

0 commit comments

Comments
 (0)