Skip to content

Commit

Permalink
endpoint to initiate fulltext reindexing
Browse files Browse the repository at this point in the history
  • Loading branch information
abaevbog committed Jun 18, 2023
1 parent 2cf66c3 commit eb0a76e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
18 changes: 18 additions & 0 deletions controllers/FullTextController.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,4 +157,22 @@ public function itemContent() {

$this->end();
}

public function reindex() {
$this->allowMethods(['POST']);

// Check for general library access
if (!$this->permissions->canAccess($this->objectLibraryID)) {
$this->e403();
}

$lambdaClient = Z_Core::$AWS->createLambda();
$result = $lambdaClient->invoke([
'FunctionName' => Z_CONFIG::$REINDEX_LAMBDA_FUNCTION_NAME,
'InvocationType' => 'Event',
'Payload' => json_encode(['libraryID' => $this->objectLibraryID]),
]);
$this->end();
}

}
2 changes: 2 additions & 0 deletions include/config/routes.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@
$router->map('/users/i:objectUserID/fulltext', array('controller' => 'FullText', 'action' => 'fulltext'));
//$router->map('/users/i:objectUserID/publications/fulltext', ['controller' => 'FullText', 'action' => 'fulltext', 'extra' => ['publications' => true]]);
$router->map('/groups/i:objectGroupID/fulltext', array('controller' => 'FullText', 'action' => 'fulltext'));
$router->map('/groups/i:objectGroupID/fulltext/reindex', array('controller' => 'FullText', 'action' => 'reindex'));
$router->map('/users/i:objectUserID/fulltext/reindex', array('controller' => 'FullText', 'action' => 'reindex'));

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

0 comments on commit eb0a76e

Please sign in to comment.