XF 2.2 Reindex one single thread and posts

Robert9

Well-known member
Is it possible to reindex only one single thread for the search?
What is needed to make this thread and its posts to be reindexed?

Will a change of posts with

Post content find / replace​

reindex thread and posts?


I am too lazy, so i will add some hundreds of posts in one and the same thread just by sql.
After that this thread must be reindexed. What can I do to solve this without reindex the whole forum, please?
 
What's the worry about re-indexing the entire forum? Do you have millions of posts that may slow it down?
Honestly, the CRON to re-index should be fairly efficient (and quick) if you have adequate hardware.
 
What's the worry about letting other people their own will?

💐
Because it's trying to suck more out of an ounce of sugar than is there?

What you appear to want is a one off instance. Before many will want to purse that rabbit hole, they may want to know the reason why when there is an easier process to pursue? I have a distinct feeling that what you want to do will involve more time than a simple re-index of the entire site unless you have a VERY big site.
Not to mention the fact that simply adding posts by an SQL injection will simply NOT complete other related requirements of the script. There are many other requirements to meet than simply putting a thread in a node.
 
There is no GUI to reindex a single thread, but doing that isn't terrible difficult if you have shell access and you don't need anything fancy (and with serious error checking)

PHP:
$dir = __DIR__;
require($dir . '/src/XF.php');

XF::start($dir);

$app = \XF::setupApp('XF\Pub\App');

// Set the Thred ID here
$threadId = 1;

$thread = \XF::em()->find('XF:Thread', $threadId);

if (!$thread)
{
    die('Invalid Thread ID given');
}

$postIds = \XF::finder('XF:Post')
    ->where('thread_id', $thread->thread_id)
    ->fetch()
    ->pluckNamed('post_id');

$search = $app->search();
$search->indexByIds('thread', [$threadId]);

if (!empty($postIds))
{
    $search->indexByIds('post', $postIds);
}
 
Top Bottom