sitecore搜索的基本用法

M.R*_*.R. 7 c# asp.net sitecore content-management-system sitecore6

我正在尝试设置一个非常基本的搜索索引,以索引特定文件夹中的所有项目.我没有真正使用太多的搜索,但我正在尝试使用开箱即用的功能,因为它是一个非常简单的搜索.我只想索引所有字段.sitecore文档确实没有提供太多信息 - 我已经阅读了一些博客,他们似乎都建议我需要高级数据库爬虫(http://trac.sitecore.net/AdvancedDatabaseCrawler) - 基本上,是如果没有自定义抓取工具,它将无效.

这是正确的吗?我只想创建一个简单的索引,然后开始使用它.没有任何共享模块或其他方式,最简单的方法是什么?我浏览了sitecore上的文档,但不是很清楚(至少对我而言).它定义了web.config中索引配置的不同元素,但并没有真正解释它们的作用以及可用的值.也许我不是在寻找合适的地方..

Mar*_*lak 15

Sitecore中创建新Lucene索引的简单方法,只需3个步骤,即可在特定节点下创建所有项目:

1:在下面添加到配置configuration/sitecore/search/configuration/indexesSitecore的配置:

<!-- id must be unique -->
<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 itmes from master database -->
      <Database>master</Database>
      <!-- your folder path -->
      <Root>/sitecore/content/home/my/specific/folder</Root>
    </specificfolder>
  </locations>
</index>
Run Code Online (Sandbox Code Playgroud)

2:重建新索引(仅一次,将自动检测所有进一步的更改):

SearchManager.GetIndex("my-custom-index").Rebuild();
Run Code Online (Sandbox Code Playgroud)

3:使用新索引:

// use id of from the index configuration
using (IndexSearchContext indexSearchContext = SearchManager.GetIndex("my-custom-index").CreateSearchContext())
{
    // MatchAllDocsQuery will return everything. Use proper query from the link below
    SearchHits hits = indexSearchContext.Search(new MatchAllDocsQuery(), int.MaxValue);
    // Get Sitecore items from the results of the query
    List<Item> items = hits.FetchResults(0, int.MaxValue).Select(result => result.GetObject<Item>()).Where(item => item != null).ToList();
}
Run Code Online (Sandbox Code Playgroud)

这是一个描述Sitecore搜索和索引的pdf .

这是一篇关于Sitecore Lucene搜索和索引排除故障的博客文章.

这是Lucene查询语法教程

介绍Lucene.Net