Sitecore的搜索非常基本的用法 [英] Very basic usage of sitecore search

查看:579
本文介绍了Sitecore的搜索非常基本的用法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想建立一个非常基本的搜索索引,索引中的特定文件夹中的所有项目。我还没有真正使用太多的搜索,但我试图用外的现成的功能,因为它的一个非常简单的搜索。我只是想索引的所有领域。该Sitecore的文件确实没有提供太多的信息 - 我读了一些博客,他们都似乎表明,我需要先进的数据库抓取(<一个href=\"http://trac.sitecore.net/AdvancedDatabaseCrawler\">http://trac.sitecore.net/AdvancedDatabaseCrawler) - 基本上,东西的效果,将没有自定义的履带式工作)。

I am trying to setup a very basic search index, to index all items in a specific folder. I haven't really used much searching, but I'm trying to use out-of-the-box features, because its a very simple search. I just want to index all the fields. The sitecore documentation really doesn't provide much information - I've read a few blogs, and they all seem to suggest that I need the advanced database crawler (http://trac.sitecore.net/AdvancedDatabaseCrawler) - basically, something to the effect of 'it won't work without a custom crawler).

这是正确的?我只是想创建一个简单的索引,然后开始使用它。什么是做到这一点最简单的方法,不需要任何共享的模块或以其他方式?我通过文件继续Sitecore的,但它不是很清楚(至少对我来说)。它定义在web.config中的索引配置不同的元素,但并没有真正解释他们做了什么,以及什么值可用。也许我不希望在正确的地方。

Is this right? I just want to create a simple index, and then start using it. What is the simplest way to do this, without any shared modules or otherwise? I went through the documentation on sitecore, but its not very clear (at least to me). It defines different elements of the index configuration in web.config, but doesn't really explain what they do, and what values are available. Maybe I'm not looking in the right place..

推荐答案

Sitecore的与特定节点下的所有项目在创造新的 Lucene的指数的一种简单方法刚刚3个步骤:

A simple way of creating new Lucene index in Sitecore with all the items below the specific node in just 3 steps:

1 添加下面的配置到配置/ Sitecore的/搜索/配置/索引 Sitecore的配置

1: Add the configuration below to the configuration/sitecore/search/configuration/indexes in Sitecore configuration:

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

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

2: Rebuild the new index (only one time, all further changes will be detected automatically):

SearchManager.GetIndex("my-custom-index").Rebuild();

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();
}

下面是描述一个PDF <一个href=\"http://sdn.sitecore.net/upload/sitecore6/66/sitecore_search_and_indexing_sc66-usletter.pdf\">Sitecore搜索和索引。

Here is a pdf describing Sitecore Search and Indexing.

这是关于<一个博客帖子href=\"http://www.cognifide.com/blogs/sitecore/troubleshooting-sitecore-lucene-search-and-indexing/\">Troubleshooting Sitecore的Lucene搜索和索引。

下面是 Lucene的查询语法教程​​

介绍Lucene.Net

这篇关于Sitecore的搜索非常基本的用法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆