sitecore搜索的基本用法
我正在尝试设置一个非常基本的搜索索引,以索引特定文件夹中的所有项目。 我没有真正使用太多的搜索,但我正在尝试使用开箱即用的function,因为它是一个非常简单的搜索。 我只想索引所有字段。 sitecore文档确实没有提供太多信息 – 我已经阅读了一些博客,他们似乎都建议我需要高级数据库爬虫( http://trac.sitecore.net/AdvancedDatabaseCrawler ) – 基本上,是如果没有自定义抓取工具,它将无效。
这是正确的吗? 我只想创建一个简单的索引,然后开始使用它。 没有任何共享模块或其他方式,最简单的方法是什么? 我浏览了sitecore上的文档,但不是很清楚(至少对我而言)。 它定义了web.config中索引配置的不同元素,但并没有真正解释它们的作用以及可用的值。 也许我不是在寻找合适的地方..
在Sitecore中创建新Lucene索引的简单方法,只需3个步骤即可在特定节点下创建所有项目:
1:将以下配置添加到Sitecore配置中的configuration/sitecore/search/configuration/indexes
:
$(id) __my-custom-index master /sitecore/content/home/my/specific/folder
2:重建新索引(仅一次,将自动检测所有进一步的更改):
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- items = hits.FetchResults(0, int.MaxValue).Select(result => result.GetObject
- ()).Where(item => item != null).ToList(); }
这是一个描述Sitecore搜索和索引的pdf。
这是一篇关于Sitecore Lucene搜索和索引排除故障的博客文章。
这是Lucene查询语法教程
并介绍Lucene.Net
Sitecore Search Contrib(高级数据库爬虫的新名称)是最佳选择,您只需在app config文件夹中配置其配置即可告诉它启动路径数据库等。
然后,您可以使用其API在文件夹中按模板类型搜索特定字段具有特定值的位置。 这是一个代码示例。
MultiFieldSearchParam parameters = new MultiFieldSearchParam(); parameters.Database = "web"; parameters.InnerCondition = QueryOccurance.Should; parameters.FullTextQuery = searchTerm; parameters.TemplateIds = array of pipe seperated ID's var refinements = Filters.Select(item => new MultiFieldSearchParam.Refinement(item.Value, item.Key.ToString())).ToList(); parameters.Refinements = refinements;
//实际搜索
var returnItems = new List- (); var runner = new QueryRunner(IndexName); var skinnyItems = runner.GetItems(new[] {parameters}); skinnyItems.ForEach(x => returnItems.Add(Database.GetItem(new ItemUri(x.ItemID)))); return returnItems;
否则,您只需配置web.config以进行标准lucene搜索,并使用此代码进行搜索。 (数据库使用“web”,开始项目等)
public Item[] Search(string searchterms) { var children = new List- (); var searchIndx = SearchManager.GetIndex(IndexName); using (var searchContext = searchIndx.CreateSearchContext()) { var ftQuery = new FullTextQuery(searchterms); var hits = searchContext.Search(ftQuery); var results = hits.FetchResults(0, hits.Length); foreach (SearchResult result in results) { if (result.GetObject
- () != null) { //Regular sitecore item returned var resultItem = result.GetObject
- (); if (ParentItem == null) { children.Add(resultItem); } else if (resultItem.Publishing.IsPublishable(DateTime.Now, false) && ItemUtilities.IsDecendantOfItem(ParentItem, resultItem)) { children.Add(resultItem); } } } } return children.ToArray(); }
然后,您可以下载Sitecore的Lucene Index Viewer扩展程序以查看索引,也可以下载Lucene Tool以查看索引。 查看是否可以填充文档(索引中的文件)。 这些在Lucene中称为“文档”,从技术上讲,这些文档是您指定的节点下的内容项。
布莱恩佩德森有一个很好的post。 您将从一个简单的爬虫开始。 需要下载高级数据库爬网程序,并在构建后添加对项目的引用。
然后你必须创建Brian博客中提到的配置文件,你必须按原样复制(除了模板ID的全部)。 你基本上得到了这一点。
然后,您可以下载Sitecore的Lucene Index Viewer扩展程序以查看索引,也可以下载Lucene Tool以查看索引。 查看是否可以填充文档(索引中的文件)。 这些在Lucene中称为“文档” ,从技术上讲,这些文档是您指定的节点下的内容项。
希望这可以帮助!
让我谷歌那个给你。
- ASP.NET – 如何向服务器发出AJAX请求而不获取我所有更新面板的信息响应?
- Crystal Report不显示在使用VS 2013构建的ASP.net网页中
- 如何在Asp.net中回发后维护标签的价值?
- 好的asp.net(C#)应用程序?
- 如何将远程服务器数据库与本地数据库同步
- 通过asp.net中的TextBoxes进行迭代 – 为什么这不起作用?
- 如何在我的自定义表而不是aspnet用户中使用哈希密码保存新记录?
- Include路径表达式必须引用在type.in eager loading上定义的导航属性
- 云网络服务器上的wkhtmltopdf.exe System.Security.SecurityException。 如何覆盖服务器安全策略