検索エンジンを修正しようとしています。問題は、既存のブログ アイテムを検索すると、常に次のように表示されることです。
Did not match in any document
何を検索しても、常にそのエラー メッセージが表示されます。
これを修正する方法はありますか、それとも私のコードに問題がありますか?
@using Examine.LuceneEngine.SearchCriteria
@inherits Umbraco.Web.Macros.PartialViewMacroPage
string searchTerm = Request.QueryString["search"];
var searcher = ExamineManager.Instance.SearchProviderCollection["MySiteSearcher"];
var searchCriteria = searcher.CreateSearchCriteria();
var query = searchCriteria.Field("nodeName", searchTerm).Or().Field("bodyText", searchTerm).Compile();
var searchResults = searcher.Search(query);
@if (searchResults.Any()){
<ul class="search-results">
@foreach (var result in searchResults)
{
IPublishedContent node = Umbraco.Content(result.Fields["id"]);
<li>
<a href="@umbraco.library.NiceUrl(result.Id)">
@if (result.Fields.ContainsKey("nodeName")) {
@node.GetPropertyValue("blogItemTitle")
}
</a>
<p>@result.Fields["blogbodyText"]</p>
</li>
}
</ul>
} else {
<p class="error-result">
Your search
@if (!String.IsNullOrEmpty(searchTerm))
{
<strong><text>'@searchTerm'</text></strong>
}
did not match any documents.
</p>
}
これが私の設定です
<?xml version="1.0"?>
<!--
Umbraco examine is an extensible indexer and search engine.
This configuration file can be extended to add your own search/index providers.
Index sets can be defined in the ExamineIndex.config if you're using the standard provider model.
More information and documentation can be found on CodePlex: http://umbracoexamine.codeplex.com
-->
<Examine>
<ExamineIndexProviders>
<providers>
<add name="InternalIndexer" type="UmbracoExamine.UmbracoContentIndexer, UmbracoExamine"
supportUnpublished="true"
supportProtected="true"
interval="10"
analyzer="Lucene.Net.Analysis.WhitespaceAnalyzer, Lucene.Net"/>
<add name="InternalMemberIndexer" type="UmbracoExamine.UmbracoMemberIndexer, UmbracoExamine"
supportUnpublished="true"
supportProtected="true"
interval="10"
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="MySiteIndexer" type="UmbracoExamine.UmbracoMemberIndexer, UmbracoExamine"
supportUnpublished="false"
supportProtected="true"
interval="10"
analyzer="Lucene.Net.Analysis.Standard.StandardAnalyzer, Lucene.Net"
enableDefaultEventHandler="true"/>
</providers>
</ExamineIndexProviders>
<ExamineSearchProviders defaultProvider="ExternalSearcher">
<providers>
<add name="InternalSearcher" type="UmbracoExamine.UmbracoExamineSearcher, UmbracoExamine"
analyzer="Lucene.Net.Analysis.WhitespaceAnalyzer, Lucene.Net"/>
<add name="InternalMemberSearcher" type="UmbracoExamine.UmbracoExamineSearcher, UmbracoExamine"
analyzer="Lucene.Net.Analysis.Standard.StandardAnalyzer, Lucene.Net" enableLeadingWildcard="true"/>
<add name="ExternalSearcher" type="UmbracoExamine.UmbracoExamineSearcher, UmbracoExamine" />
<add name="MySiteSearcher" type="UmbracoExamine.UmbracoExamineSearcher, UmbracoExamine"
analyzer="Lucene.Net.Analysis.Standard.StandardAnalyzer, Lucene.Net"
enableLeadingWildcards="true"
indexSet="MySiteIndexSet"/>
</providers>
</ExamineSearchProviders>
</Examine>
ExamineIndex.config
<?xml version="1.0"?>
<!--
Umbraco examine is an extensible indexer and search engine.
This configuration file can be extended to create your own index sets.
Index/Search providers can be defined in the UmbracoSettings.config
More information and documentation can be found on CodePlex: http://umbracoexamine.codeplex.com
-->
<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" EnableSorting="true"/>
<add Name="name" EnableSorting="true"/>
<add Name="updateDate" />
<add Name="writerName" />
<add Name="loginName" />
<add Name="email" />
<add Name="bodyText"/>
<add Name="blogItemTitle" />
<add Name="nodeTypeAlias" />
</IndexAttributeFields>
<IndexUserFields>
<add Name="bodyText"/>
<add Name="tags"/>
<add Name="content"/>
<add Name="tags" />
<add Name="category" />
</IndexUserFields>
<IncludeNodeTypes>
<add Name="article" />
<add Name="note" />
<add Name="KnowledgebaseItem" />
</IncludeNodeTypes>
</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="MySiteIndexSet" IndexPath="~/App_Data/TEMP/ExamineIndexes/MySiteSearcher/" />
</ExamineLuceneIndexSets>