From d8f9ca86a59be9788377314ab3b7f70e1a2e7583 Mon Sep 17 00:00:00 2001 From: Maksim Sukharev Date: Wed, 4 Feb 2026 17:13:30 +0100 Subject: [PATCH 1/2] fix(Command): try to actualize values for document indexing Signed-off-by: Maksim Sukharev --- lib/Command/DocumentIndex.php | 5 +++++ lib/Command/DocumentProvider.php | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/lib/Command/DocumentIndex.php b/lib/Command/DocumentIndex.php index 431ba437..85dba401 100644 --- a/lib/Command/DocumentIndex.php +++ b/lib/Command/DocumentIndex.php @@ -57,6 +57,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int $index = new Index($providerId, $documentId); $index->setOwnerId($userId); $index->setStatus(Index::INDEX_FULL); + try { + $index = \OC::$server->get(\OCA\FullTextSearch\Service\IndexService::class)->getIndex($providerId, $documentId); + } catch (\Throwable $t) { + $output->writeln("Index not found : index attribute has been set to default values"); + } $indexDocument = $provider->updateDocument($index); if (!$indexDocument->hasIndex()) { $indexDocument->setIndex($index); diff --git a/lib/Command/DocumentProvider.php b/lib/Command/DocumentProvider.php index a7e73877..b0409e99 100644 --- a/lib/Command/DocumentProvider.php +++ b/lib/Command/DocumentProvider.php @@ -58,6 +58,11 @@ protected function execute(InputInterface $input, OutputInterface $output) { $index = new Index($providerId, $documentId); $index->setOwnerId($userId); $index->setStatus(Index::INDEX_FULL); + try { + $index = \OC::$server->get(\OCA\FullTextSearch\Service\IndexService::class)->getIndex($providerId, $documentId); + } catch (\Throwable $t) { + $output->writeln("Index not found : index attribute has been set to default values"); + } $indexDocument = $provider->updateDocument($index); $index->setOwnerId($indexDocument->getAccess()->getOwnerId()); From 6ff39dcaadc1424d39ff54b5cb5a34dd8a1a44f4 Mon Sep 17 00:00:00 2001 From: Ghassen kefi Date: Mon, 14 Sep 2026 13:08:32 +0200 Subject: [PATCH 2/2] Fix: document index values in fulltextsearch OCC commands Signed-off-by: Ghassen kefi --- lib/Command/DocumentIndex.php | 14 ++++++++++---- lib/Command/DocumentProvider.php | 13 +++++++++---- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/lib/Command/DocumentIndex.php b/lib/Command/DocumentIndex.php index 85dba401..2811fdfc 100644 --- a/lib/Command/DocumentIndex.php +++ b/lib/Command/DocumentIndex.php @@ -11,9 +11,12 @@ use Exception; use OC\Core\Command\Base; +use OCA\FullTextSearch\Exceptions\IndexDoesNotExistException; use OCA\FullTextSearch\Model\Index; +use OCA\FullTextSearch\Service\IndexService; use OCA\FullTextSearch\Service\PlatformService; use OCA\FullTextSearch\Service\ProviderService; +use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -22,6 +25,7 @@ class DocumentIndex extends Base { public function __construct( private ProviderService $providerService, private PlatformService $platformService, + private IndexService $indexService, ) { parent::__construct(); } @@ -36,7 +40,8 @@ protected function configure() { ->setDescription('index one specific document') ->addArgument('userId', InputArgument::REQUIRED, 'userId') ->addArgument('providerId', InputArgument::REQUIRED, 'providerId') - ->addArgument('documentId', InputArgument::REQUIRED, 'documentId'); + ->addArgument('documentId', InputArgument::REQUIRED, 'documentId') + ->addOption('collection', null, InputOption::VALUE_OPTIONAL, 'collection to look the existing index up in, defaults to the internal collection'); } /** @@ -50,6 +55,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int $providerId = $input->getArgument('providerId'); $documentId = $input->getArgument('documentId'); $userId = $input->getArgument('userId'); + $collection = $input->getOption('collection'); $providerWrapper = $this->providerService->getProvider($providerId); $provider = $providerWrapper->getProvider(); @@ -58,9 +64,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int $index->setOwnerId($userId); $index->setStatus(Index::INDEX_FULL); try { - $index = \OC::$server->get(\OCA\FullTextSearch\Service\IndexService::class)->getIndex($providerId, $documentId); - } catch (\Throwable $t) { - $output->writeln("Index not found : index attribute has been set to default values"); + $index = $this->indexService->getIndex($providerId, $documentId, $collection); + } catch (IndexDoesNotExistException $e) { + $output->writeln('Index not found: index attributes have been set to default values'); } $indexDocument = $provider->updateDocument($index); if (!$indexDocument->hasIndex()) { diff --git a/lib/Command/DocumentProvider.php b/lib/Command/DocumentProvider.php index b0409e99..059dac12 100644 --- a/lib/Command/DocumentProvider.php +++ b/lib/Command/DocumentProvider.php @@ -11,7 +11,9 @@ use Exception; use OC\Core\Command\Base; +use OCA\FullTextSearch\Exceptions\IndexDoesNotExistException; use OCA\FullTextSearch\Model\Index; +use OCA\FullTextSearch\Service\IndexService; use OCA\FullTextSearch\Service\ProviderService; use OCP\FullTextSearch\Model\IIndexDocument; use Symfony\Component\Console\Input\InputArgument; @@ -22,6 +24,7 @@ class DocumentProvider extends Base { public function __construct( private ProviderService $providerService, + private IndexService $indexService, ) { parent::__construct(); } @@ -37,7 +40,8 @@ protected function configure() { ->addArgument('userId', InputArgument::REQUIRED, 'userId') ->addArgument('providerId', InputArgument::REQUIRED, 'providerId') ->addArgument('documentId', InputArgument::REQUIRED, 'documentId') - ->addOption('content', 'c', InputOption::VALUE_NONE, 'return some content'); + ->addOption('content', 'c', InputOption::VALUE_NONE, 'return some content') + ->addOption('collection', null, InputOption::VALUE_OPTIONAL, 'collection to look the existing index up in, defaults to the internal collection'); } @@ -51,6 +55,7 @@ protected function execute(InputInterface $input, OutputInterface $output) { $providerId = $input->getArgument('providerId'); $documentId = $input->getArgument('documentId'); $userId = $input->getArgument('userId'); + $collection = $input->getOption('collection'); $providerWrapper = $this->providerService->getProvider($providerId); $provider = $providerWrapper->getProvider(); @@ -59,9 +64,9 @@ protected function execute(InputInterface $input, OutputInterface $output) { $index->setOwnerId($userId); $index->setStatus(Index::INDEX_FULL); try { - $index = \OC::$server->get(\OCA\FullTextSearch\Service\IndexService::class)->getIndex($providerId, $documentId); - } catch (\Throwable $t) { - $output->writeln("Index not found : index attribute has been set to default values"); + $index = $this->indexService->getIndex($providerId, $documentId, $collection); + } catch (IndexDoesNotExistException $e) { + $output->writeln('Index not found: index attributes have been set to default values'); } $indexDocument = $provider->updateDocument($index);