Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • overflew 87 posts 110 karma points
    Jul 27, 2010 @ 02:52
    overflew
    0

    Examine config - Multiple Indexers, and aligning to IndexSets

    Hi,

    I'm trying to set up multiple IndexSets, so I can cover the different properties two key document types. (There are a few thousand of each).

    I have the indexes building in the App_Data dir, and I'm able to create an ISearchCriteria object with the code below, and can successfully search over NodeName.

    .SearchProviderCollection["CompanySearcher"].CreateSearchCriteria()

    However, I get the feeling the Search/Index Providers aren't correctly linked to the IndexSet, as adding any Field() criteria goes on to return no results...

    Am I missing something simple with lining up the IndexSet to the SearchProvider? Is it currently just using the internal index? 

    My ExamineIndex.config looks like this:

    <ExamineLuceneIndexSets>
      <!-- The internal index set used by Umbraco back-office - DO NOT REMOVE -->
      <IndexSet SetName="InternalIndexSet" IndexPath="~/App_Data/ExamineIndexes/Internal/">
        <IndexAttributeFields>
          <add Name="id" />
          <add Name="nodeName" />
          <add Name="updateDate" />
          <add Name="writerName" />
          <add Name="path" />
          <add Name="nodeTypeAlias" />
          <add Name="parentID" />
        </IndexAttributeFields>
        <IndexUserFields />
        <IncludeNodeTypes/>
        <ExcludeNodeTypes />
      </IndexSet>
    
        <IndexSet SetName="ProjectIndexSet" IndexPath="~/App_Data/ExamineIndexes/Project/">
            <IndexAttributeFields>
                <add Name="id" />
                <add Name="nodeName" />
                <add Name="updateDate" />
                <add Name="nodeTypeAlias" />
            </IndexAttributeFields>
            <IndexUserFields>
                <add Name="projectStatus" />
            </IndexUserFields>
            <IncludeNodeTypes>
                <add Name="Project" />
            </IncludeNodeTypes>
            <ExcludeNodeTypes />
        </IndexSet>
      <IndexSet SetName="CompanyIndexSet" IndexPath="~/App_Data/ExamineIndexes/Company/">
            <IndexAttributeFields>
                <add Name="id" />
                <add Name="nodeName" />
                <add Name="updateDate" EnableSorting="true" />
                <add Name="nodeTypeAlias" />
            </IndexAttributeFields>
            <IndexUserFields>
                <add Name="companyRole" />
            </IndexUserFields>
            <IncludeNodeTypes>
                <add Name="Company" />
            </IncludeNodeTypes>
            <ExcludeNodeTypes />
        </IndexSet>
    </ExamineLuceneIndexSets>
    

    And ExamineSettings.config

    <Examine>
      <ExamineIndexProviders>
        <providers>
          <add name="InternalIndexer" type="UmbracoExamine.LuceneExamineIndexer, UmbracoExamine"
               runAsync="true"
               supportUnpublished="true"
               supportProtected="true"
               interval="10"
               analyzer="Lucene.Net.Analysis.Standard.StandardAnalyzer, Lucene.Net"/>
    
        <add name="ProjectIndexer" type="UmbracoExamine.LuceneExamineIndexer, UmbracoExamine"
               runAsync="true"
               supportUnpublished="false"
           indexSet="ProjectIndexSet"
               supportProtected="true"
               interval="10"
               analyzer="Lucene.Net.Analysis.WhitespaceAnalyzer, Lucene.Net"/>
        <add name="CompanyIndexer" type="UmbracoExamine.LuceneExamineIndexer, UmbracoExamine"
               runAsync="true"
               supportUnpublished="false"
           indexSet="CompanyIndexSet"
               supportProtected="true"
               interval="10"
               analyzer="Lucene.Net.Analysis.Standard.StandardAnalyzer, Lucene.Net"/>
        </providers>
      </ExamineIndexProviders>
    
      <ExamineSearchProviders defaultProvider="InternalSearcher">
        <providers>
          <add name="InternalSearcher" type="UmbracoExamine.LuceneExamineSearcher, UmbracoExamine"
               analyzer="Lucene.Net.Analysis.Standard.StandardAnalyzer, Lucene.Net"/>
    
        <add name="ProjectSearcher" type="UmbracoExamine.LuceneExamineSearcher, UmbracoExamine"
             indexSet="ProjectIndexSet"
               analyzer="Lucene.Net.Analysis.WhitespaceAnalyzer, Lucene.Net"/>
        <add name="CompanySearcher" type="UmbracoExamine.LuceneExamineSearcher, UmbracoExamine"
            indexSet="CompanyIndexSet"
               analyzer="Lucene.Net.Analysis.Standard.StandardAnalyzer, Lucene.Net"/>
            </providers>
      </ExamineSearchProviders>
    
    </Examine>

    (Will be expanding the indexed user fields once I have it working...)

    So the following works:

     

     

    ISearchCriteria sc = ExamineManager.Instance.SearchProviderCollection["CompanySearcher"].CreateSearchCriteria();
    IBooleanOperation query = sc.NodeTypeAlias("Company");
    query = query.And().NodeName(searchCriteria.NodeName.MultipleCharacterWildcard());
    IEnumerable<SearchResult> results = ExamineManager.Instance.Search(query.Compile());

     

    However, including a line like this will stop it from returning anything:

    query = query.And().Field("companyRole", searchCriteria.CompanyRole.Value.ToString());

    Am I missing something simple with lining up the IndexSet to the SearchProvider? Is it currently just using the internal index? 

    Any and all help appreciated, thanks.

     

  • Aaron Powell 1708 posts 3046 karma points c-trib
    Jul 28, 2010 @ 00:52
    Aaron Powell
    0

    What's the Lucene query that's being generated (you can see it from the ToString method of the ISearchCriteria object)?

Please Sign in or register to post replies

Write your reply to:

Draft