Skip to content

Commit eb0a76e

Browse files
committed
endpoint to initiate fulltext reindexing
1 parent 2cf66c3 commit eb0a76e

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

controllers/FullTextController.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,4 +157,22 @@ public function itemContent() {
157157

158158
$this->end();
159159
}
160+
161+
public function reindex() {
162+
$this->allowMethods(['POST']);
163+
164+
// Check for general library access
165+
if (!$this->permissions->canAccess($this->objectLibraryID)) {
166+
$this->e403();
167+
}
168+
169+
$lambdaClient = Z_Core::$AWS->createLambda();
170+
$result = $lambdaClient->invoke([
171+
'FunctionName' => Z_CONFIG::$REINDEX_LAMBDA_FUNCTION_NAME,
172+
'InvocationType' => 'Event',
173+
'Payload' => json_encode(['libraryID' => $this->objectLibraryID]),
174+
]);
175+
$this->end();
176+
}
177+
160178
}

include/config/routes.inc.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@
4242
$router->map('/users/i:objectUserID/fulltext', array('controller' => 'FullText', 'action' => 'fulltext'));
4343
//$router->map('/users/i:objectUserID/publications/fulltext', ['controller' => 'FullText', 'action' => 'fulltext', 'extra' => ['publications' => true]]);
4444
$router->map('/groups/i:objectGroupID/fulltext', array('controller' => 'FullText', 'action' => 'fulltext'));
45+
$router->map('/groups/i:objectGroupID/fulltext/reindex', array('controller' => 'FullText', 'action' => 'reindex'));
46+
$router->map('/users/i:objectUserID/fulltext/reindex', array('controller' => 'FullText', 'action' => 'reindex'));
4547

4648
// All trashed items
4749
$router->map('/users/i:objectUserID/items/trash', array('controller' => 'Items', 'extra' => array('subset' => 'trash')));

0 commit comments

Comments
 (0)