Copied to clipboard

Flag this post as spam?

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


  • Tim 1193 posts 2675 karma points MVP 4x c-trib
    Jul 28, 2011 @ 13:46
    Tim
    0

    Only Index Content Nodes in Examine

    Hi,

    I've got a custom index set up that my site search is using. However, the indexer is indexing content AND media nodes. Although the search means that the media nodes won't show up, I'd quite like to not have them in the index, as the site is going to have a LOT of media nodes in it.

    Does anyone know a way of doing this?

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Jul 28, 2011 @ 14:37
    Dirk De Grave
    1

    Tim,

    Aren't you in control of what is being indexed if you're creating a custom index? Add your media doc types to the list of node types to exclude

    <IndexSet ...>
      ...
      <ExcludeNodeTypes>
        <add Name="Image" />
      </ExcludeNodeTypes>
    </IndexSet> 

    Or did I misunderstand the question?

     

    Cheers,

    /Dirk

  • Tim 1193 posts 2675 karma points MVP 4x c-trib
    Jul 28, 2011 @ 15:24
    Tim
    0

    Hi Dirk!

    I've done that already (as I'm already excluding settings sections etc), but if someone adds a new media type to the system, they have to remember to update the index as well to exclude it. I was wondering if there was a blanket way to get it to just index content or media nodes. There's a setting on the index provider called "indexTypes" but I can't get that to work, and the documentation for it isn't that great.

    Its not the end of the world as they won't add custom media types often, but it'd be nice to do if you know how?

  • bob baty-barr 1180 posts 1294 karma points MVP
    Jul 28, 2011 @ 16:28
    bob baty-barr
    0

    hey guys... along the same lines... is there a way to exclude items that have been moved to the trash from the index?

    thanks!

  • Tim 1193 posts 2675 karma points MVP 4x c-trib
    Jul 29, 2011 @ 17:13
    Tim
    0

    @Bob,

    Is your index set to index unpublished content? For indexes used for front end searches, I exclude unpublised stuff, that way, items in the recycle bin should be excluded, as they're unpublished when they get moved to the bin.

  • bob baty-barr 1180 posts 1294 karma points MVP
    Jul 29, 2011 @ 17:37
    bob baty-barr
    0

    @Tim, by default isn't supportUnpublished set to false?

  • Tim 1193 posts 2675 karma points MVP 4x c-trib
    Jul 29, 2011 @ 17:49
    Tim
    0

    Yeah, it looks like it is! I always set it to false just to be on the safe side! :P one other thing to check, is the item in the recycle bin actually unpublished? I've had an issue in the past where there's somehow been items in the recycle bin that aren't unpublished!

  • bob baty-barr 1180 posts 1294 karma points MVP
    Jul 29, 2011 @ 17:54
    bob baty-barr
    0

    yeah, the site i am working on, it appears to be moslty related to media files in the recycle bin... i am indexing pdf files as well as content.

  • Vladimir Knobel 95 posts 171 karma points
    Jun 30, 2012 @ 19:54
    Vladimir Knobel
    0

    It seems that can be control using something like

    ExamineManager.Instance.SearchProviderCollection["MySearcher"].CreateSearchCriteria(IndexTypes.Content);

    where the key is CreateSearchCriteria(IndexTypes.Content)

    although in my installation Umbraco 4.7.1.1 CreateSearchCriteria() only takes a string to define the type not an enum...

    Hope this helps

    Vlad 

     

  • Carlos Casalicchio 176 posts 736 karma points
    Dec 22, 2013 @ 02:02
    Carlos Casalicchio
    0
    @using Examine
    @using Examine.SearchCriteria
    @using UmbracoExamine
    @{
      var searchString = Request["searchstring"];
      if (!String.IsNullOrEmpty(searchString))  {
    var searchProvider = ExamineManager.Instance.DefaultSearchProvider.Name;
    var examine = ExamineManager.Instance.SearchProviderCollection[searchProvider];
    examine.CreateSearchCriteria(IndexTypes.Content);
    var searchResults = examine.Search(searchString, true);
    
    foreach (var c in searchResults)
    {
      <div>
        <h3><a href="@umbraco.library.NiceUrl(c.Id)" target="_blank">@c.Fields["nodeName"]</a></h3>
        @if(c.Fields.Keys.Contains("bodyText"))
        {
          var bodyText = c.Fields["bodyText"];
          if (bodyText.Length>100)
          {
            bodyText = bodyText.Substring(0,100);
          }
          <p>@Html.Raw(bodyText)</p>
        }
      </div>    
    }  
    }
    

    }

    I'm using Umbraco v6.1.6 (Assembly version: 1.0.5021.24867) but search results are still coming with media. What am I doing wrong?

  • Carlos Casalicchio 176 posts 736 karma points
    Dec 26, 2013 @ 17:58
    Carlos Casalicchio
    0

    Does any one have any suggestions on how to display only Content (filter) using Examine? (my code is below)

          var searchString = Request["searchstring"];
    
          if (!String.IsNullOrEmpty(searchString))  {
              var searchProvider = ExamineManager.Instance.DefaultSearchProvider.Name;
              var examine = ExamineManager.Instance.SearchProviderCollection[searchProvider];
              examine.CreateSearchCriteria(IndexTypes.Content);
              var searchResults = examine.Search(searchString, true);
    }
    
Please Sign in or register to post replies

Write your reply to:

Draft