簡體   English   中英

Sitecore Lucene搜索索引和子文件夾

[英]Sitecore Lucene search indexing and subfolders

我如何使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>

聽起來您正在使用Sitecore市場中的Lucene搜索模塊。 該模塊的代碼將搜索結果限制為網站根目錄及其子目錄:

 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模塊\\ Lucene Search \\ SearchManager.cs

假設Web.config的sites部分中的“ website”節點具有startItem =“ / home”,則不會返回“ home”層次結構之外的結果。

如果您下載該項目的源代碼,並將填充SiteRoot的行編輯為以下內容,則將返回新項目:

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

請記住將新的LuceneSearch.dll復制到網站項目的bin目錄中。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM