0

I have configured examine indexing in umbraco 7, it index some pages but not all, for example i have two pages of same document type one of them is index in search but portion of text content above image in rich text editor and below that image content is also not index ? Unable to figure out mistake, here is my Examine config

ExamineIndex.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>

ExamineSettings.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>

Macro Code:

@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>
        }

    }
 }
4

1 回答 1

0
if (!string.IsNullOrEmpty(Request.QueryString["search"]))

我在这里遇到了同样的问题。所以这就是我做错了。现在,您正在“请求”一个名为“search”的“QueryString”。您没有该查询字符串。另一方面,您需要创建它。

您现在拥有的只是一个string命名的"search",而不是一个QueryString因此Request.Querystring["search"]返回的值null

我在执行此操作时在控制器中使用 MVC,我的逻辑最终告诉我,我应该做的是在我的模型中搜索名为“search”的变量。基本上我用 if 替换了原来的

if (!string.IsNullOrEmpty(model.search))
{
Your code here
}

这样做是告诉控制器去在我的“模型”中找到名为“search”的变量,并且“如果”!string.IsNullOrEmpty,然后在下面执行我的代码。

我还没有阅读您的整个代码,正如我所说的那样,我在执行此操作时使用了 MVC,因此请根据需要将其调整为您自己的代码。

于 2016-09-22T10:10:40.037 回答