Sitecore Lucene搜索索引和子文件夹

时间:2013-02-01 11:21:49

标签: search lucene sitecore root

如何让Lucene包含结果,索引在siteroot之外,例如。基于fx。“/ sitecore / content / stuff”的东西,但不能放在“/ sitecore / content / Home”中。

查看“/ sitecore modules / LuceneSearch /中的SearchManager.cs,SiteRoot被定义为”SiteCore.Content.Site.Startpath“,但对此文件进行任何更改似乎都有任何影响。

注意:
我只使用“LuceneResults”.ascx&的.cs。

-----问题更新了,因为我缩小了问题的范围-----

我试图创建一组特定项目的索引,用于Lucene搜索 在web.config中,我指定了一个包含以下内容的索引:

 ...
 <root>/sitecore/content/Home/Subfolder</root>
 ...

并且完美无缺,在搜索时获得所有子项目。

然后我将完全相同的项目复制到新位置,并更新了我的web.config,如下所示:

 ...
 <root>/sitecore/content/newSubfolder/Subfolder/Subfolder</root>
 ...

现在我的搜索从未找到任何内容! 有没有人知道这里可能出现什么问题。

注意:
- 我在每次更改时都重建了搜索索引数据库 - 在“Luke”中,索引看起来很好,这里的搜索产生了正确的结果。

完整索引:

<index id="faqindex" type="Sitecore.Search.Index, Sitecore.Kernel">
    <param desc="name">$(id)</param>
    <param desc="folder">__faq</param>
    <Analyzer ref="search/analyzer"/>
    <locations hint="list:AddCrawler">
        <resources type="Sitecore.Search.Crawlers.DatabaseCrawler, Sitecore.Kernel">
            <database>master</database>
                      <root>/sitecore/content/MyContent/Snippets/FAQ</root>
            <include hint="list:IncludeTemplate">
                <faqblock>{3340AAAE-B2F8-4E22-8B7B-F3EDDB48587E}</faqblock>
            </include>
            <tags>faqblock</tags>
            <boost>1.0</boost>
        </resources>
    </locations>
</index>

1 个答案:

答案 0 :(得分:0)

听起来您正在使用Sitecore Marketplace中的 Lucene Search 模块。此模块的代码将搜索结果限制为站点根目录及其子项:

 public SearchManager(string indexName)
 {
   SearchIndexName = indexName;
   Database database = Factory.GetDatabase("master");
   var item = Sitecore.Context.Site.StartPath;
   SiteRoot = database.GetItem(item);
}
[...]
public SearchResultCollection Search(string searchString)
{
  //Getting index from the web.config
  var searchIndex = Sitecore.Search.SearchManager.GetIndex(SearchIndexName);
  using(IndexSearchContext context = searchIndex.CreateSearchContext())
  {
     SearchHits hits = context.Search(searchString, new SearchContext(SiteRoot));

sitecore modules \ Lucene Search \ SearchManager.cs

假设Web.config的 sites 部分中的“website”节点具有startItem =“/ home”,则不会返回“home”层次结构之外的结果。

如果您下载此项目的源代码,并编辑将SiteRoot填充到以下内容的行,则会返回新项目:

SiteRoote = database.GetItem("/sitecore/content");

请记住将新的LuceneSearch.dll复制到网站项目的bin目录中。

相关问题