Skip to content

Commit efe4337

Browse files
committed
Keyword sanitize on aggs & base migration, close #11
1 parent bf16243 commit efe4337

File tree

3 files changed

+34
-2
lines changed

3 files changed

+34
-2
lines changed

src/DSL/Bridge.php

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

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

src/Schema/Builder.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,16 @@ 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+
281+
272282

273283
//----------------------------------------------------------------------
274284
// Builders

src/Schema/IndexBlueprint.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,22 @@ 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+
183+
168184
//----------------------------------------------------------------------
169185
// Helpers
170186
//----------------------------------------------------------------------

0 commit comments

Comments
 (0)