2015-05-19 64 views
2

我正在学习如何为Sitecore 6.6设置和配置Lucene搜索索引。我将一个基本配置文件拼凑在一起,该文件将所有类型为“文章”模板的项目索引到树中所需的位置,并能够将所有项目从该索引中提取出来并显示结果中的名称。Sitecore 6.6 - 设置Lucene索引

现在我准备好定制该索引。我需要专门索引两个字段,并且遇到配置语法问题。这是两个领域的细分。我希望有人能够帮助我调整配置来解释这些字段。

Meta关键词 - 该字段(单行文本)不是文章模板的一部分,而是从另一个名为Meta Base的模板中提取,该文章从该文章继承。我不需要存储这个,只需要索引它就可以搜索。恩。值“ortho,pain,joint”

类别 - 此字段是指向树中类别项目的可用列表的下拉链接。我确实需要存储以及索引它,以便可以在搜索/显示这些Lucene文档的结果页面上使用它。

我似乎无法找到6.6的正确文档。 7+以上的文档存在,但它们在6.6中不起作用,因为事情似乎发生了显着变化。 Sitecore支持指导我一些旧文档,其中包含不推荐使用的代码以及没有编译的代码,而我读过的所有内容似乎都指向使用Contrib Search(我已经通过NuGet提取)。我想让它在没有Contrib的情况下工作,但是如果我需要的话,我会的。

这里是我的配置我没有了contrib东西创建:

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/"> 
<sitecore> 
<search> 
    <configuration> 
    <indexes> 
     <index id="my-custom-index" type="Sitecore.Search.Index, Sitecore.Kernel"> 
     <!-- name - not sure if necessary but use id and forget about it --> 
     <param desc="name">$(id)</param> 

     <!-- folder - name of directory on the hard drive --> 
     <param desc="folder">__my-custom-index</param> 

     <!-- analyzer - reference to analyzer defined in Sitecore.config --> 
     <Analyzer ref="search/analyzer" /> 

     <!-- list of locations to index - each of the with unique xml tag --> 
     <locations hint="list:AddCrawler"> 

      <!-- first location (and the only one in this case) - specific folder from you question --> 
      <!-- type attribute is the crawler type - use default one in this scenario --> 
      <specificfolder type="Sitecore.Search.Crawlers.DatabaseCrawler,Sitecore.Kernel"> 

      <!-- indexing items from web database --> 
      <Database>web</Database> 

      <!-- your folder path --> 
      <Root>/sitecore/content/Northwestern/in-care</Root> 

      <!-- Article Template --> 
      <include hint="list:IncludeTemplate"> 
       <ContentHubArticle>{1E79E463-631A-4FBB-BEEA-3304D25F29CD}</ContentHubArticle> 
      </include> 

      <indexAllFields>true</indexAllFields> 
      </specificfolder> 
     </locations> 



     </index> 
    </indexes> 
    </configuration> 
</search> 

+0

暂且,其实我已经禁用了SearchContrib指数,下定决心要摆脱的最现成的指标工作。我已经安装了indexviewer模块,并且由于 true设置,我能够看到所有字段都获得了索引,尽管它们没有被存储,只有索引。我想禁用该设置,并只索引上面提到的两个字段,存储所提到的droplink值。我怀疑droplink会更困难,而且需要自定义代码,所以我先从单行文本框开始。 – tjans

+0

查看下面的3篇博文。他们应该回答你的所有问题:https://www.cognifide.com/blogs/sitecore/sitecore-6-lucene-search-the-most-basic-setup/ https://www.cognifide.com/blogs/sitecore /故障排除-Sitecore的-的Lucene搜索和索引/ https://www.cognifide.com/blogs/sitecore/troubleshooting-sitecore-lucene-search-and-indexing/ –

+0

马立克,在那里你打算发布另一个链接?最后两个是对方的愚蠢。此外,我已经完成了这两个,他们都让我到现在的位置,但不提供如何指定特定字段进行索引以及如何配置是存储它们还是仅索引它们的解决方案,也不提供他们是否提供有关如何处理droplink字段的解决方案。 – tjans

回答

0

与Sitecore支持人员交谈时,他们绝对称这不能用开箱即用的功能完成。我能够利用这一系列的博客文章得到它的索引我的领域:

http://sitecoregadgets.blogspot.com/2009/10/working-with-lucene-search-index-part-i.html http://sitecoregadgets.blogspot.com/2009/11/working-with-lucene-search-index-in.html http://sitecoregadgets.blogspot.com/2009/11/working-with-lucene-search-index-in_25.html http://sitecoregadgets.blogspot.com/2010/08/adding-custom-fields-to-index.html http://sitecoregadgets.blogspot.com/2010/07/sitecore-lucene-index-does-not-remove.html

的唯一剩下的就是让droplink场店不同的场比指向该项目的guid,但我认为这里有足够的可以称之为答案,因为最大的问题是如何为自定义字段建立索引。当我完成后,我可能会回过头来发布整个代码,所以您不必像我一样将博客文章中的所有内容拼凑在一起,但要弄清楚发生了什么很容易。

我也upvode马立克氏后上方,因为他一直乐于助人,他的意见是非常有用的。

4

Sitecore的6 Lucene索引的最基本的设置是:

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/"> 
<sitecore> 
    <search> 
    <configuration> 
    <indexes> 
    <index id="custom-index" type="Sitecore.Search.Index, Sitecore.Kernel"> 
     <!-- name of the index displayed in the Sitecore Control Panel --> 
     <param desc="name">Custom Index</param> 
     <!-- folder in which index file will be stored --> 
     <param desc="folder">__$(id)</param> 
     <!-- reference to the analyzer defined in Sitecore config --> 
     <Analyzer ref="search/analyzer" /> 
     <!-- list of locations which will be index by our index --> 
     <locations hint="list:AddCrawler"> 
     <!-- our first and only location crawled by standard Sitecore crawler --> 
     <custom-loc-1 type="Sitecore.Search.Crawlers.DatabaseCrawler,Sitecore.Kernel"> 
     <!-- location root is Home item in master database --> 
     <Database>master</Database> 
     <Root>/sitecore/content/Home</Root> 
     </custom-loc-1> 
     </locations> 
    </index> 
    </indexes> 
    </configuration> 
    </search> 
</sitecore> 
</configuration> 

对于您需要创建自定义抓取工具类的自定义字段,例如:

public class MyCrawler : Sitecore.Search.Crawlers.DatabaseCrawler 
{ 
    protected override void 
    AddAllFields(Document document, Item item, bool versionSpecific) 
    { 
    base.AddAllFields(document, item, versionSpecific); 

    document.Add(CreateField("my_title", item["title"], false, 1)); 

    WorkflowState state = item.State.GetWorkflowState(); 
    document.Add(CreateField("my_final_state", 
     state != null && state.FinalState ? "1" : "", false, 1)); 

    document.Add(CreateDataField("data_title", item["title"])); 
    } 
} 

和注册这个爬虫类这样的:

<locations hint="list:AddCrawler"> 
    <custom-location-1 type="My.Assembly.Namespace.MyCrawler,My.Assembly"> 
    <Database>master</Database> 
    <Root>/sitecore/content/Home</Root> 
    </custom-location-1> 
</locations> 

这里的博客文章,你可以用它来了解更多关于Sitecore的6个搜索:

  1. https://www.cognifide.com/blogs/sitecore/troubleshooting-sitecore-lucene-search-and-indexing/
  2. https://www.cognifide.com/blogs/sitecore/sitecore-6-lucene-search-the-most-basic-setup/
  3. https://www.cognifide.com/blogs/sitecore/pagination-sorting-crawling-and-storing-data-with-sitecore-and-lucene/
+0

看起来我仍然需要一些配置,以便索引中的项目在发布时得到重新索引。当我重建索引时,它做得很好,但是当我发布时,更新不会更新。我尝试添加一些我曾阅读过的HistoryEngine的东西,但是这只是导致任何变化的项目从索引中删除(使用Luke确认)。 – tjans