As designed XenForo_Search_SourceHandler_MySqlFt::deleteIndex

Daniel Hood

Well-known member
It's quite possible that this is 'as designed' but I was just wondering why this method doesn't run a delete for the content type. It only does something if you don't specify a content type.

This actually causes:

upload_2015-4-13_13-29-55.webp
to ignore the checked box. I think it should be more like:

PHP:
/**
    * Deletes the entire search index or a particular part of it.
    *
    * @param string|null $contentType If specified, only deletes the index for this type
    */
public function deleteIndex($contentType = null)
    {
        if (!$contentType)
        {
            XenForo_Application::getDb()->query('TRUNCATE TABLE xf_search_index');
        }
        else
        {
            XenForo_Application::getDb()->delete('xf_search_index', 'content_type = ' . $this->_getDb()->quote($contentType));
        }
    }
 
This is intentional as truncation is fast (it just creates a new table). A delete like that is likely to be very slow if you have a significant amount of data (causing a long lock on the table too).
 
Fair enough. Was just thinking it was odd that the "Delete index" checkbox wasn't doing anything (as I only wanted to empty a small portion of mine). Maybe a note should be placed there for people not using ElasticSearch?
 
Top Bottom