在后台进程中重建 Sitecore 搜索索引和链接数据库

发布于 2024-07-26 12:06:14 字数 346 浏览 4 评论 0原文

我们有一个包含 1 个 CMS 和 3 个从属服务器的分阶段环境,

我想在从属服务器上创建一个页面,成功发布后分阶段模块将调用该页面,这将重建所有索引和链接数据库。

我知道我可以使用:

Globals.LinkDatabase.Rebuild(Factory.GetDatabase("web"));

重建链接数据库。

如何在可以访问 sitecore 上下文的单独进程中获取上述代码,以及如何重建 Web 数据库的所有索引 - 再次在单独的后台线程中。

谢谢

We have a staged environment with 1 CMS and 3 Slave servers

I want to create a page on the slave server, which will be called by the staging module on a successful publish, that will rebuild all indexes and the links database.

I know I can use:

Globals.LinkDatabase.Rebuild(Factory.GetDatabase("web"));

to rebuild the link database.

How do I get the above code in a separate process that has access to the sitecore context and also how do I rebuild all the indexes for the web database - again in a separate background thread.

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

客…行舟 2024-08-02 12:06:14

我之前在使用 Sitecore 时遇到过这个问题,并采取了稍微不同的方法。 我没有使用暂存模块调用的页面,而是点击了发布:结束事件并添加了自定义处理程序来重建链接数据库。

<event name="publish:end">
    <handler type="Sitecore.Publishing.HtmlCacheClearer, Sitecore.Kernel" method="ClearCache">
        <sites hint="list">
            <site>website</site>
        </sites>
    </handler>
    <handler type="Sitecore.EventHandlers.CredentialCacheClearer, Sitecore.EventHandlers" method="ClearCache">
        <sites hint="list">
            <site>website</site>
        </sites>
    </handler>

    // Custom Publish Action Below
    <handler type="Customized.Publish.LinkDatabase, Customized" method="Process"/>
</event>
namespace Customized.Publish
{
    public class LinkDatabase
    {
        /// <summary>
        /// Rebuild the web link database.
        /// </summary>

        public void Process()
        {
            // Web db
            Sitecore.Globals.LinkDatabase.Rebuild(Sitecore.Configuration.Factory.GetDatabase("web"));
        }

        /// <summary>
        /// For invoking as an event, typically publish:end.
        /// </summary>
        public void Process(object sender, EventArgs args)
        {
            this.Process();
        }
    }
}

I've come across this issue before with Sitecore and took a slightly different approch. Instead of having a page that the staging module calls I tapped into the publish:end event and added a custom handler to rebuild the Link Database.

<event name="publish:end">
    <handler type="Sitecore.Publishing.HtmlCacheClearer, Sitecore.Kernel" method="ClearCache">
        <sites hint="list">
            <site>website</site>
        </sites>
    </handler>
    <handler type="Sitecore.EventHandlers.CredentialCacheClearer, Sitecore.EventHandlers" method="ClearCache">
        <sites hint="list">
            <site>website</site>
        </sites>
    </handler>

    // Custom Publish Action Below
    <handler type="Customized.Publish.LinkDatabase, Customized" method="Process"/>
</event>
namespace Customized.Publish
{
    public class LinkDatabase
    {
        /// <summary>
        /// Rebuild the web link database.
        /// </summary>

        public void Process()
        {
            // Web db
            Sitecore.Globals.LinkDatabase.Rebuild(Sitecore.Configuration.Factory.GetDatabase("web"));
        }

        /// <summary>
        /// For invoking as an event, typically publish:end.
        /// </summary>
        public void Process(object sender, EventArgs args)
        {
            this.Process();
        }
    }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文