From da068085ef6608fdcec3a528d398a11fca626f04 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Sun, 17 Oct 2021 11:51:13 +0545 Subject: [PATCH] add search field in storage buckets --- app/config/collections2.php | 20 +++++++++++++++++++- app/controllers/api/storage.php | 2 ++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/app/config/collections2.php b/app/config/collections2.php index 6f09688ac..19bdc62d7 100644 --- a/app/config/collections2.php +++ b/app/config/collections2.php @@ -2127,6 +2127,17 @@ $collections = [ 'required' => true, 'array' => false, ], + [ + '$id' => 'search', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 16384, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], ], 'indexes' => [ [ @@ -2135,7 +2146,14 @@ $collections = [ 'attributes' => ['name'], 'lengths' => [1024], 'orders' => [Database::ORDER_ASC], - ] + ], + [ + '$id' => '_key_search', + 'type' => Database::INDEX_FULLTEXT, + 'attributes' => ['search'], + 'lengths' => [2048], + 'orders' => [Database::ORDER_ASC], + ], ] ], diff --git a/app/controllers/api/storage.php b/app/controllers/api/storage.php index 70b914b4a..63c687c85 100644 --- a/app/controllers/api/storage.php +++ b/app/controllers/api/storage.php @@ -254,6 +254,7 @@ App::post('/v1/storage/buckets') 'antiVirus' => $antiVirus, '$read' => $read, '$write' => $write, + 'search' => implode(' ', [$bucketId, $name]), ])); } catch (Duplicate $th) { throw new Exception('Bucket already exists', 409); @@ -603,6 +604,7 @@ App::post('/v1/storage/buckets/:bucketId/files') 'sizeActual' => $sizeActual, 'algorithm' => empty($compressor) ? '' : $compressor->getName(), 'comment' => '', + 'search' => implode(' ', [$fileId, $file['name'] ?? '',]), ]; if($bucket->getAttribute('encryption', true) && $size <= APP_LIMIT_ENCRYPTION) {