【问题标题】:Search specific folder using sitecore search使用 sitecore 搜索搜索特定文件夹
【发布时间】:2012-01-06 11:46:12
【问题描述】:

我希望能够仅在某个目录中进行搜索。例如。假设用户点击了网站顶部的“不同类型的火车”链接。然后,此页面有一个带有搜索框的不同类型火车的列表。我想要用户在搜索框中输入的任何内容,只是为了搜索“火车类型”部分中的页面——/sitecore/content/LOTW/Home/trains 中的任何内容,并且网站上没有其他页面。我目前正在使用:

protected void searchIcon_Click(object sender, EventArgs e)
{
    PerformSearch();
}

private void PerformSearch()
{
    /* Changed from Shared Source, to use different path finding, and context database */

    Item pointerItem = Sitecore.Context.Database.SelectSingleItem("/sitecore/content/LOTW/Global/Settings/Config/Pointers/Search Results");

    if (pointerItem != null)
    {
        Item results = Sitecore.Context.Database.GetItem(new ID(pointerItem["Item"]));

        if (results != null)
        {

            string results_url = LinkManager.GetItemUrl(results) + "?search=" + Server.UrlEncode(search.Text);
            Response.Redirect(results_url);
        }
        else
        {
            search.ForeColor = Color.Red;
            search.Text = "Unable to find results item";
        }

    }
}

这会搜索整个网站。我对 Sitecore 中的搜索一无所知,所以我有点迷茫!

【问题讨论】:

  • 我有点困惑。您发布的代码似乎只处理查找搜索页面并重定向到它。它不是实际的搜索代码。不过,我建议您为每个部分创建唯一索引以搜索和使用 Advanced Database Crawler

标签: search sitecore


【解决方案1】:

Sitecore 确实在项目上具有 Axis 命名空间,允许您访问特定项目的后代,但如果您有超过 25 个子项,则搜索会变得非常慢。

要快速搜索,请使用 Lucene 索引。 Sitecore 是 Lucene 索引的标准配置。

为简化对索引的访问,您应该下载Advanced Database Crawler免费软件/开源模块。

您可以在此处阅读有关如何设置以及如何访问索引的更多信息:

Using the Sitecore open source AdvancedDatabaseCrawler Lucene indexer

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-02-08
    • 1970-01-01
    相关资源
    最近更新 更多