Umbraco检查搜索索引
本文关键字:索引 搜索 检查 Umbraco | 更新日期: 2023-09-27 18:24:10
我在umbraco 7中配置了检查索引,它索引了一些页面,但不是所有页面,例如,我有两个相同文档类型的页面,其中一个在搜索中是索引,但富文本编辑器中图像上方和图像下方的部分文本内容也不是索引?无法找出错误,这是我的检查配置
ExaminerIndex.config:
<ExamineLuceneIndexSets>
<!-- The internal index set used by Umbraco back-office - DO NOT REMOVE -->
<IndexSet SetName="InternalIndexSet" IndexPath="~/App_Data/TEMP/ExamineIndexes/Internal/"/>
<!-- The internal index set used by Umbraco back-office for indexing members - DO NOT REMOVE -->
<IndexSet SetName="InternalMemberIndexSet" IndexPath="~/App_Data/TEMP/ExamineIndexes/InternalMember/">
<IndexAttributeFields>
<add Name="id" />
<add Name="nodeName"/>
<add Name="updateDate" />
<add Name="writerName" />
<add Name="loginName" />
<add Name="email" />
<add Name="nodeTypeAlias" />
</IndexAttributeFields>
</IndexSet>
<!-- Default Indexset for external searches, this indexes all fields on all types of nodes-->
<IndexSet SetName="ExternalIndexSet" IndexPath="~/App_Data/TEMP/ExamineIndexes/External/" />
<IndexSet SetName="MySearch" IndexPath="~/App_Data/ExamineIndexes/MySearch/">
<IndexAttributeFields>
<add Name="id" />
<add Name="nodeName"/>
<add Name="updateDate" />
<add Name="writerName" />
<add Name="nodeTypeAlias" />
</IndexAttributeFields>
<IndexUserFields>
<add Name="pageBodyText"/>
<add Name="bodyText"/>
<add Name="title"/>
<add Name="summary"/>
<add Name="projectTitle"/>
<add Name="projectDescription"/>
<add Name="rightBoxContent"/>
<add Name="leftBoxContent"/>
<!--<add Name="siteName"/>-->
</IndexUserFields>
<IncludeNodeTypes>
<!--<add Name="umbHomePage" />-->
<add Name="umbHomePage" />
<add Name="Page" />
<add Name="NewsItem" />
<add Name="Project" />
<add Name="Service" />
<add Name="Client" />
<!--<add Name="PageWithPlugin" />-->
<!--NewsItem,Project,Service,Page,umbHomePage,Client-->
</IncludeNodeTypes>
</IndexSet>
<!--<IndexSet SetName="MySearchIndexer" IndexPath="~/App_Data/TEMP/ExamineIndexes/MySearchIndexer/" />-->
</ExamineLuceneIndexSets>
ExaminerSettings.config:
<Examine>
<ExamineIndexProviders>
<providers>
<add name="InternalIndexer" type="UmbracoExamine.UmbracoContentIndexer, UmbracoExamine"
supportUnpublished="true"
supportProtected="true"
analyzer="Lucene.Net.Analysis.WhitespaceAnalyzer, Lucene.Net"/>
<add name="InternalMemberIndexer" type="UmbracoExamine.UmbracoMemberIndexer, UmbracoExamine"
supportUnpublished="true"
supportProtected="true"
analyzer="Lucene.Net.Analysis.Standard.StandardAnalyzer, Lucene.Net"/>
<!-- default external indexer, which excludes protected and unpublished pages-->
<add name="ExternalIndexer" type="UmbracoExamine.UmbracoContentIndexer, UmbracoExamine"/>
<add name="MySearchIndexer" type="UmbracoExamine.UmbracoContentIndexer, UmbracoExamine"
supportUnpublished="false"
supportProtected="true"
interval="10"
analyzer="Lucene.Net.Analysis.Standard.StandardAnalyzer, Lucene.Net"
indexSet="MySearch"/>
<!--<add name="MySearchSearcher" type="UmbracoExamine.UmbracoExamineSearcher, UmbracoExamine"
analyzer="Lucene.Net.Analysis.Standard.StandardAnalyzer, Lucene.Net" indexSet="MySearch" enableLeadingWildcards="true"/>-->
</providers>
</ExamineIndexProviders>
<ExamineSearchProviders defaultProvider="ExternalSearcher">
<providers>
<add name="InternalSearcher" type="UmbracoExamine.UmbracoExamineSearcher, UmbracoExamine"
analyzer="Lucene.Net.Analysis.WhitespaceAnalyzer, Lucene.Net"/>
<add name="ExternalSearcher" type="UmbracoExamine.UmbracoExamineSearcher, UmbracoExamine" />
<add name="InternalMemberSearcher" type="UmbracoExamine.UmbracoExamineSearcher, UmbracoExamine"
analyzer="Lucene.Net.Analysis.Standard.StandardAnalyzer, Lucene.Net" enableLeadingWildcard="true"/>
<add name="MySearchSearcher" type="UmbracoExamine.UmbracoExamineSearcher, UmbracoExamine"
analyzer="Lucene.Net.Analysis.Standard.StandardAnalyzer, Lucene.Net" indexSet="MySearch" enableLeadingWildcards="true" />
</providers>
</ExamineSearchProviders>
</Examine>
宏代码:
@inherits Umbraco.Web.Macros.PartialViewMacroPage
@using Examine.LuceneEngine.SearchCriteria
@{
if (!string.IsNullOrEmpty(Request.QueryString["search"]))
{
var q = Request.QueryString["search"];
var Searcher = Examine.ExamineManager.Instance.SearchProviderCollection["MySearchSearcher"];
var searchResults = Searcher.Search(q, true).OrderByDescending(x => x.Score).TakeWhile(x => x.Score > 0.05f);
bool isRecordFound = false;
<ul>
@foreach (var item in searchResults)
{
IPublishedContent node = Umbraco.Content(item.Fields["id"]);
<li>
<a href="@node.Url">
@node.Name
</a>
</li>
isRecordFound = true;
}
</ul>
if (!isRecordFound)
{
<div>
<h1>No Record Found</h1>
</div>
}
}
}
if (!string.IsNullOrEmpty(Request.QueryString["search"]))
我也有同样的问题。这就是我做错的地方。现在,您正在"请求"一个名为"搜索"的"QueryString"。您没有该查询字符串。另一方面,你需要创建它
您现在所拥有的只是一个名为"search"
的string
,而不是一个QueryString
,因此Request.Querystring["search"]
返回值null
。
当我在控制器中使用MVC时,我的逻辑最终告诉我,我应该做的是在模型中搜索名为"search"的变量。基本上我用替换了原来的if
if (!string.IsNullOrEmpty(model.search))
{
Your code here
}
这样做是告诉控制器在我的"模型"answers"if"中找到名为"search"的变量!一串IsNullOrEmpty,然后在下面执行我的代码。
我还没有读过你的全部代码,正如我所说,我在做这件事时使用了MVC,所以根据你的需要将其调整为你自己的代码。