Reindex search without command line

Hello, is there a way to reindex search without command line?
I receive This script can only be executed from the command-line when trying to run tools/runScheduledTasks.php from the browser. But unfortunatelly i don’t have CLI available on my hosting plan.
Corresponding tables (submission_search*) are all empty, cache/_db is also empty - guess that’s quite understandable.
Is there any way to go around please? Or is for example reindexing automatically performed when some event happens (new issue published or anything).

Thanks a lot, Tomas

Hi @Tomas_Ruprich,

Generally speaking, tasks of this nature, or anything using scheduled tasks have to be run via command line with appropriate server access, which in your case, unfortunately, your host may not provide access to.

-Roger
PKP Team

Hi Roger, thanks for clarification.

Actually i was able to run simple reindex just by moving piece of code from tools/rebuildSearchIndex.php to pkp/pages/admin/AdminHandler.inc.php:

    # Testing reindex Search Base from web
	public function callbackBaseUrl($hookName, $params) {
		$baseUrl =& $params[0];
		$baseUrl = Config::getVar('general', 'base_url');
		return true;
	}
	function rebuildSearchIndex() {
		$switches = array();
		$journal = null;
		HookRegistry::register('Request::getBaseUrl', array($this, 'callbackBaseUrl'));
		$articleSearchIndex = Application::getSubmissionSearchIndex();
		$articleSearchIndex->rebuildIndex(true, $journal, $switches);
	}

and adding to switch in pkp/pages/admin/index.php

	case 'rebuildSearchIndex':

and calling host/index.php/index/admin/rebuildSearchIndex runs fine:
Clearing index ... done Indexing "Journal xxx" ... 197 articles indexed

I thought i might create Issue around it on GitHub, but it seems it’s not generally wanted behavior from what you write. I see the tool counts with external plugins, so it should probably stay just in CLI version. So i’m just sending it to forum for case anyone else could use it…

Thanks for your time Roger (and also rest of the team, thanks for your work)

Hi @Tomas_Ruprich,

Thanks for sharing your customization - very interesting. I’m going to flag my colleague @NateWr here - as he (or another member of our Dev Team) can speak to the suitability of this customization for Github issues. Can you also indicate which version of OJS you’re running?

-Roger
PKP Team

I’m having 3.3.0-4 now.
This was just onetimer for me, i can rewrite it to more suitable form and create standard merge request.
Thaks, Tom

Thanks @Tomas_Ruprich. Rebuilding the search index on large sites can lead to timeouts, so I would guess that’s why we’re hesitant to add a button for it in the admin area. For 3.4, we’re working on a better system for job queues and processing. Once that’s in place it will hopefully be easier to handle long-running tasks like this outside of the CLI.