diff --git a/app/config/collections.php b/app/config/collections.php index cf21df2ebf..33a60fce44 100644 --- a/app/config/collections.php +++ b/app/config/collections.php @@ -1728,7 +1728,7 @@ $commonCollections = [ [ '$id' => ID::custom('_key_search'), 'type' => Database::INDEX_FULLTEXT, - 'attributes' => ['name'], + 'attributes' => ['search'], 'lengths' => [], 'orders' => [Database::ORDER_ASC], ] diff --git a/app/controllers/api/messaging.php b/app/controllers/api/messaging.php index 567c8e2cd6..0147e472bb 100644 --- a/app/controllers/api/messaging.php +++ b/app/controllers/api/messaging.php @@ -1400,6 +1400,9 @@ App::post('/v1/messaging/topics') if ($description) { $topic->setAttribute('description', $description); + $topic->setAttribute('search', $topic->getId() . ' ' . $name . ' ' . $description); + } else { + $topic->setAttribute('search', $topic->getId() . ' ' . $name); } try { @@ -1516,6 +1519,16 @@ App::patch('/v1/messaging/topics/:topicId') $topic->setAttribute('description', $description); } + if (!empty($name) || !empty($description)) { + if (!empty($name) && !empty($description)) { + $topic->setAttribute('search', $topic->getId() . ' ' . $name . ' ' . $description); + } elseif (!empty($name)) { + $topic->setAttribute('search', $topic->getId() . ' ' . $name . ' ' . $topic->getAttribute('description')); + } else { + $topic->setAttribute('search', $topic->getId() . ' ' . $topic->getAttribute('name') . ' ' . $description); + } + } + $topic = $dbForProject->updateDocument('topics', $topicId, $topic); $response diff --git a/tests/e2e/Services/Messaging/MessagingBase.php b/tests/e2e/Services/Messaging/MessagingBase.php index b3a075d579..65e196db30 100644 --- a/tests/e2e/Services/Messaging/MessagingBase.php +++ b/tests/e2e/Services/Messaging/MessagingBase.php @@ -223,7 +223,7 @@ trait MessagingBase 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-key' => $this->getProject()['apiKey'], ], [ - 'topicId' => 'unique()', + 'topicId' => ID::unique(), 'name' => 'my-app', 'description' => 'web app' ]); @@ -258,6 +258,8 @@ trait MessagingBase 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], 'x-appwrite-key' => $this->getProject()['apiKey'], + ], [ + 'search' => 'updated-description', ]); $this->assertEquals(200, $response['headers']['status-code']); $this->assertEquals(1, \count($response['body']['topics']));