Introduction
If you are using XenForo Enhanced Search (XFES) with Elasticsearch, you may encounter a situation where the Similar Threads widget does not appear, even though it is enabled and configured correctly.
This issue is not caused by a simple misconfiguration. It is usually related to how XenForo and Elasticsearch interact, especially regarding indexing and cache generation.
This guide explains the real root cause, the exact fix, and whether this is a one-time issue or something that needs ongoing maintenance.
Problem Symptoms
You may observe one or more of the following:
- Similar Threads widget is enabled but not visible
- Widget appears only on some threads
- Most threads show no similar content
- XFES is installed and Elasticsearch is running, but results are empty
Root Cause
The core issue is simple: the Elasticsearch index is empty or not properly populated.
XFES does not generate similar threads using MySQL. It relies entirely on Elasticsearch through a query called:
Code:
moreLikeThis()
If the index is empty, no similarity data can be generated, the cache remains empty, and the widget returns no output.
Additionally, XenForo stores similar thread results in the following table:
Code:
xf_es_thread_similar
If this table contains empty values in the similar_thread_ids field, the widget will not render.
Why Did This Happen?
This issue typically occurs in a few common situations. XFES may have been installed after content already existed. The search index may never have been rebuilt. Cron jobs may not have been running. Elasticsearch authentication may have prevented proper indexing. In some cases, similar thread cache records were created before Elasticsearch was fully ready.
So even though XFES is enabled, the widget is enabled, and Elasticsearch itself is running, the forum still has no usable similarity data.
Step by Step Fix
Step 1: Rebuild the Search Index
Run the following command:
Code:
php cmd.php xf-rebuild:search
This rebuilds the XenForo search index, sends content to Elasticsearch, and makes similarity queries possible.
Step 2: Mark Similar Thread Cache for Rebuild
Run:
Code:
UPDATE xf_es_thread_similar SET pending_rebuild = 1;
This tells XenForo that all similar thread cache records should be rebuilt.
Step 3: Queue the Similar Threads Job
Run:
Code:
INSERT INTO xf_job (unique_key, execute_class, execute_data, manual_execute, trigger_date)
VALUES ('xfesSimilarThreads', 'XFES:SimilarThreads', 'a:0:{}', 0, UNIX_TIMESTAMP())
ON DUPLICATE KEY UPDATE trigger_date = UNIX_TIMESTAMP();
This places the XFES similar threads rebuild job into the XenForo job queue.
Step 4: Run the XenForo Jobs
Run:
Code:
php cmd.php xf:run-jobs --max-execution-time=0
This processes the queued rebuild tasks until everything is finished.
Step 5: Rebuild Master Data
Run:
Code:
php cmd.php xf:rebuild-master-data
This refreshes important XenForo internal data and helps updated widget positions and caches become visible immediately.
Step 6: Verify the Elasticsearch Index
Run:
Code:
curl -k -u USERNAME:PASSWORD https://localhost:9200/YOUR_INDEX/_count
If the count is greater than zero, the index is populated correctly.
Step 7: Verify Similar Thread Cache
You can also confirm that similar thread cache is being filled:
Code:
SELECT thread_id, similar_thread_ids
FROM xf_es_thread_similar
WHERE thread_id = 79;
If you see thread IDs such as 78,75 or similar values, the cache is working.
Is This a One Time Fix?
The answer is yes in most cases, but not always.
If this happened because XFES was installed recently, because the index was never built, or because the cache was generated before Elasticsearch was working properly, then this is usually a one-time repair. Once the index is rebuilt and the cache is refreshed, Similar Threads should continue to work normally.
However, the same problem can return if Elasticsearch is reinstalled, the index is deleted, the server is migrated, authentication settings are changed, or XenForo background jobs stop running.
Will Future Updates Require the Same Manual Fix?
Normally, no.
Once everything is configured correctly, XenForo and XFES should handle this automatically. New content is indexed, similar thread cache is refreshed in the background, and the widget continues working without manual intervention.
You should not need to repeat the full repair process after every update.
However, after major server changes, Elasticsearch resets, or search configuration changes, it is a good idea to verify that the search index is still populated.
Recommended Automation
To avoid future issues, make sure XenForo jobs run regularly through cron.
Example cron entry:
Code:
* * * * * php /home/USERNAME/public_html/cmd.php xf:run-jobs
This ensures background jobs always run, cache stays updated, and manual intervention is rarely needed.
Final Conclusion
The Similar Threads issue in XenForo is usually not caused by a broken widget or a broken theme.
In most real cases, it is caused by missing Elasticsearch data, an unbuilt search index, or empty similarity cache records.
Once the search index is rebuilt, the similar thread cache is refreshed, and XenForo jobs are running correctly, the system works as expected and should remain stable without repeated manual fixes.