diff --git a/app/config/collections2.php b/app/config/collections2.php index 04410de8f8..9ee235ce56 100644 --- a/app/config/collections2.php +++ b/app/config/collections2.php @@ -2149,6 +2149,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' => [ [ @@ -2157,7 +2168,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 bbb3c8fc5f..a53fb004ee 100644 --- a/app/controllers/api/storage.php +++ b/app/controllers/api/storage.php @@ -244,7 +244,27 @@ App::post('/v1/storage/buckets') 'array' => false, 'filters' => [], ]), + new Document([ + [ + '$id' => 'search', + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 16384, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + ]), ], [ + new Document([ + '$id' => '_key_search', + 'type' => Database::INDEX_FULLTEXT, + 'attributes' => ['search'], + 'lengths' => [2048], + 'orders' => [Database::ORDER_ASC], + ]), new Document([ '$id' => '_key_bucket', 'type' => Database::INDEX_KEY, @@ -252,13 +272,6 @@ App::post('/v1/storage/buckets') 'lengths' => [Database::LENGTH_KEY], 'orders' => [Database::ORDER_ASC], ]), - new Document([ - '$id' => '_fulltext_name', - 'type' => Database::INDEX_FULLTEXT, - 'attributes' => ['name'], - 'lengths' => [1024], - 'orders' => [Database::ORDER_ASC], - ]), ]); $bucket = $dbForInternal->createDocument('buckets', new Document([ @@ -276,6 +289,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); @@ -682,6 +696,7 @@ App::post('/v1/storage/buckets/:bucketId/files') 'openSSLCipher' => $openSSLCipher, 'openSSLTag' => $openSSLTag, 'openSSLIV' => $openSSLIV, + 'search' => implode(' ', [$fileId, $fileName,]), ])); } else { $file = $dbForInternal->updateDocument('bucket_' . $bucketId, $fileId, $file @@ -715,6 +730,7 @@ App::post('/v1/storage/buckets/:bucketId/files') 'comment' => '', 'chunksTotal' => $chunks, 'chunksUploaded' => $chunksUploaded, + 'search' => implode(' ', [$fileId, $fileName,]), ])); } else { $file = $dbForInternal->updateDocument('bucket_' . $bucketId, $fileId, $file