Copied to clipboard

Flag this post as spam?

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


  • Frans de Jong 548 posts 1840 karma points MVP 3x c-trib
    Mar 17, 2015 @ 11:53
    Frans de Jong
    0

    Sitesearch with examin

    Hi all,

    I have some trouble with the examine sitesearch in Umbraco 7.2.2. The sitesearch is working when I only use the attributes of the result like Id and Name.

    When I use the folowing code the searchresults stays empty. I can't find any solution...

    @{
        string searchTerm = Request.QueryString["keywords"];
        if (String.IsNullOrWhiteSpace(searchTerm))
        {
            searchTerm = "";
        }      
    
        var searcher = ExamineManager.Instance;
        var searchCriteria = searcher.CreateSearchCriteria();
        var query = searchCriteria.GroupedOr(new[] { "nodeName", "name", "title", "bodyText", "seo" }, searchTerm).Compile();
        var searchResults = searcher.Search(query).Where(r => r["__IndexType"] == "content").ToList();
    }
    
    
    @if (@searchResults.Any())
    { ... Do stuff with it ...}
    

    Is this a old code snippet? Or am I doing something wrong?

    Frans

  • Frans de Jong 548 posts 1840 karma points MVP 3x c-trib
    Mar 20, 2015 @ 09:59
    Frans de Jong
    0

    I changed the following and I only get a result if I search for a nodename...

    var query = searchCriteria.GroupedOr(new[] {"nodeName", "title", "subTitle", "contentgrid", "mainHeader", "contentgrid","metaTitle" }, searchTerm).Compile();
    

    My config file looks like this:

    <?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"/>
          <add Name="updateDate" />
          <add Name="writerName" />
          <add Name="loginName" />
          <add Name="email" />
          <add Name="nodeTypeAlias" />
        </IndexAttributeFields>
        <IndexUserFields>
          <add Name="title"/>
          <add Name="subTitle"/>
          <add Name="contentgrid"/>
          <add Name="mainHeader"/>
          <add Name="contentgrid"/>
          <add Name="metaTitle"/>
        </IndexUserFields>
        <IncludeNodeTypes>
          <add Name="Home"/>
          <add Name="Contentpage"/>
          <add Name="Contactpage"/>
        </IncludeNodeTypes>
        <ExcludeNodeTypes>
        </ExcludeNodeTypes>
      </IndexSet>
    
      <!-- Default Indexset for external searches, this indexes all fields on all types of nodes-->
      <IndexSet SetName="ExternalIndexSet" IndexPath="~/App_Data/TEMP/ExamineIndexes/External/" />
    </ExamineLuceneIndexSets>   
    

    Contentgrid is a umbraco grid. Can examine index a grid?

  • Ismail Mayat 4511 posts 10091 karma points MVP 2x admin c-trib
    Mar 20, 2015 @ 15:14
    Ismail Mayat
    0

    Frans,

    Open the index using luke then see what you have in contentgrid field, i suspect its json?  Can you report back please.

    Regards

    Ismail

Please Sign in or register to post replies

Write your reply to:

Draft