简体   繁体   中英

Sitecore Lucene search indexing and subfolders

How can I make Lucene include results, indexed outside the siteroot eg. stuff based with a root of fx. "/sitecore/content/stuff", but not placed in "/sitecore/content/Home".

Taking a look at SearchManager.cs in "/sitecore modules/LuceneSearch/, the SiteRoot is defined as "SiteCore.Content.Site.Startpath", but making any changes to this file dosent seem to have any affect.

Note:
I am only using the "LuceneResults".ascx & .cs.

----- Question updated, as I narrowed in what the problem might be -----

Im trying to create an index of a specific set of items, for use in a Lucene search.
In web.config, I have specified an index containing:

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

and that works flawlessly, getting all the subitems when doen a search.

I have then copied exactly the same items to a new location, and updated my web.config as following:

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

Now my searches never finds anything!
Does anyone have an idea what could be the problem here.

Note:
- I have rebuild the Search Index db, at every change.
- In "Luke" the index seems fine, and the the search here yields the proper results.

Complete Index:

<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>

It sounds like you are using the Lucene Search module from Sitecore Marketplace. The code for this module limits the search results to the site root and its children:

 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

Assuming that the "website" node in the sites section of Web.config has startItem="/home", results outside of the "home" hierarchy will not be returned.

If you download the source code for this project, and edit the line that populates SiteRoot to the following, the new items will be returned:

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

Remember to copy the new LuceneSearch.dll to the bin directory of the website project.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM