XF 2.2 Delete the index before rebuilding? (XFES)

Neilski

Member
I'm planning to rebuild our XFES search index, because I've seen some oddities (failed searches that should have worked). Not sure of the precise causes, but I think at least some can be explained by user accounts having been merged.

In any case, I am unsure of the value of checking the box to "Delete the index before rebuilding", hence this post. There are millions of entries to index so I'm keen to only do it once :D Also, if the search system can be more or less functional during the reindexing, so much the better (and I'm guessing that this is more likely if I don't delete the index).

I have seen an old thread asking a similar question for XF 1.5 here (in which @Chris D advised not to bother deleting the index), but since this is XF 2.2 and XFES, and since I presume the option to delete the index is present for a good reason, I thought I'd better check :)
 
If I remember correctly, a rebuild does a delete first anyway.
Well, that would certainly simplify things :)
I dug in the code though, and while my PHP is flaky at best, this section from src/XF/Job/SearchRebuild.php does seem to honour the truncate option:
PHP:
class SearchRebuild extends AbstractJob
{
        protected $defaultData = [
                'type' => null,
                'rebuild_types' => null,
                'start' => 0,
                'batch' => 500,
                'delay' => 0,
                'truncate' => false,
        ];

        protected $builtType;
        protected $builtLast;

        public function run($maxRunTime)
        {
                $search = $this->app->search();

                if (!is_array($this->data['rebuild_types']) && $this->data['truncate'])
                {
                        $search->truncate($this->data['type']);
                        $this->data['truncate'] = false;
                }
 
Top Bottom