when rebuilding search index, I get this error.

Adam Dicker

when rebuilding search index, I get this error.
Any help is appreciated.

Server error log
  • XFES\Elasticsearch\BulkRequestException: Elasticsearch indexing error: Elasticsearch bulk action error (first error: [thread-550706] failed to parse [prefix])
  • src/addons/XFES/Elasticsearch/Api.php:402
  • Dec 11, 2017 at 2:19 PM
Stack trace
#0 src/addons/XFES/Elasticsearch/Api.php(171): XFES\Elasticsearch\Api->bulkRequest('{"index":{"_ind...')
#1 src/addons/XFES/Search/Source/Elasticsearch.php(82): XFES\Elasticsearch\Api->indexBulk(Array)
#2 src/XF/Search/Source/AbstractSource.php(35): XFES\Search\Source\Elasticsearch->flushBulkIndexing()
#3 src/XF/Search/Search.php(98): XF\Search\Source\AbstractSource->disableBulkIndexing()
#4 src/XF/Search/Search.php(62): XF\Search\Search->disableBulkIndexing()
#5 src/XF/Search/Search.php(85): XF\Search\Search->indexEntities('post', Object(XF\Mvc\Entity\ArrayCollection))
#6 src/XF/Job/SearchRebuild.php(57): XF\Search\Search->indexRange('post', 2256556, '500')
#7 src/XF/Job/Manager.php(241): XF\Job\SearchRebuild->run(7.99999809265)
#8 src/XF/Job/Manager.php(187): XF\Job\Manager->runJobInternal(Array, 7.99999809265)
#9 src/XF/Job/Manager.php(103): XF\Job\Manager->runJobEntry(Array, 7.99999809265)
#10 src/XF/Admin/Controller/Tools.php(120): XF\Job\Manager->runByIds(Array, 8)
#11 src/XF/Mvc/Dispatcher.php(249): XF\Admin\Controller\Tools->actionRunJob(Object(XF\Mvc\ParameterBag))
#12 src/XF/Mvc/Dispatcher.php(89): XF\Mvc\Dispatcher->dispatchClass('XF:Tools', 'run-job', 'html', Object(XF\Mvc\ParameterBag), 'tools', Object(XF\Admin\Controller\Tools), NULL)
#13 src/XF/Mvc/Dispatcher.php(41): XF\Mvc\Dispatcher->dispatchLoop(Object(XF\Mvc\RouteMatch))
#14 src/XF/App.php(1879): XF\Mvc\Dispatcher->run()
#15 src/XF.php(328): XF\App->run()
#16 admin.php(13): XF::runApp('XF\\Admin\\App')
#17 {main}
Request state
array(4) {
["url"] => string(24) "/admin.php?tools/run-job"
["referrer"] => string(47) "https://www.dnforum.com/admin.php?tools/run-job"
["_GET"] => array(1) {
["tools/run-job"] => string(0) ""
["_POST"] => array(3) {
["_xfRedirect"] => string(57) "https://www.dnforum.com/admin.php?tools/rebuild&success=1"
["_xfToken"] => string(8) "********"
["only_ids"] => string(3) "365"

Chris D

XenForo developer
Staff member
Did you have the Multi Prefix add-on installed, previously? If so, that's the cause for this.

That add-on will require an update before being able to rebuild the search index.


Well-known member
It looks like all legacy add-on data was deleted, and @Adam Dicker upgraded from XF1.x to XF2.x with a older version of Multi Prefix which didn't support XF2.

This makes troubleshooting challenging. I should have some SQL which can discard multiple prefixes to restore search, but Multi Prefix for XF2 is still on my to-do list.


Well-known member
The following should remove all multiple prefixes picking the first to keep.

Run each statement one after the other.

Please ensure you have a database backup, or at least clone the xf_thread table somewhere as this is a destructive operation and this SQL is provided as-is and is a best effort.

UPDATE xf_thread
SET prefix_id=IF(LEFT(prefix_id,LOCATE(',',prefix_id) - 1) != '', LEFT(prefix_id,LOCATE(',',prefix_id) - 1), prefix_id);
where prefix_id like '%,%';

UPDATE xf_thread
SET prefix_id = '0'
WHERE prefix_id = '';

alter table xf_thread prefix_id INT UNSIGNED NOT NULL DEFAULT 0;