Copied to clipboard

Flag this post as spam?

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


  • Douglas Robar 3562 posts 4590 karma points MVP 6x admin c-trib
    Jan 14, 2014 @ 21:13
    Douglas Robar
    0

    Media folders should not be shown in results

    (seen with Umbraco 7.0.1)

    Search results with v1.1 display items in the media section, even if they are a folder name, which doesn't have a URL. Folders should be excluded from search results.

    For instance, suppose I make a 'News Gallery' folder in the media section and put a bunch of images in the folder. If I search for 'news' I will get the following output from ezSearch in the results:

    <h2><a>News Gallery</a></h2>
    

    cheers,
    doug.

  • Matt Brailsford 1886 posts 9299 karma points MVP 5x c-trib
    Jan 14, 2014 @ 21:23
    Matt Brailsford
    0

    Hey Doug,

    Should we just exclude the "Folder" media type? or would a macro param to pass in a list of "DocTypeAliases" (defaulting to "Folder") be usefull? I'm just thinking, some people do occassionally create custom folder types, so would need a way to handle those too.

    Matt

  • Douglas Robar 3562 posts 4590 karma points MVP 6x admin c-trib
    Jan 14, 2014 @ 21:32
    Douglas Robar
    1

    I think I'd go for simple first and then see if anyone needs more. Too many macro params is daunting to users (though I'm guilty of that with my packages).

    I'd suggest a media type called 'Folder' be excluded automatically. My suspicion is that people make new media types but for specific new purposes rather than to replicate the folder functionality that exists. So in 99% of the cases I think the simple approach will work. But if I'm wrong then adding a param later would be easy enough and would still contain the logic of the simple approach suggested here so no worries about backward compatibility for users who upgrade.

    What do you think?

    cheers,
    doug.

  • Matt Brailsford 1886 posts 9299 karma points MVP 5x c-trib
    Jan 14, 2014 @ 21:49
    Matt Brailsford
    1

    No, that makes sense. 

    I think it should just be a case of adding:

    query.Append("-__NodeTypeAlias:folder ");

    after the IndexType switch statement. I just need to setup a new test site to validate it (I've reinstalled my PC since original dev so I haven't got a test site setup).

    Matt

  • Harish 15 posts 74 karma points
    Nov 20, 2014 @ 16:42
    Harish
    0

    Hi 

    I am having umbraco 6.1.6 version, and insatalled ezsearch package.

    Can any one help me out,  to exclude folder names, .png, .jpg extensions etc from ezsearch result set.......

    i need to retrive content(pages) and some media type (like .doc, .pdf )  only.

    Now when I am searching I am getting pics, folder name, which I dont want to show it in ezsearch result.

    Thanks in advance.

     

     

     

  • Ajay Karwal 31 posts 149 karma points
    Sep 18, 2015 @ 12:46
    Ajay Karwal
    1

    Has a solution for excluding Folders from search results been found yet?

    I'd like media files to still appear in results but not their Folders as this creates a search result with a broken link.

    If I have to sacrifice All media types in order to get rid of the folders I'll settle for this too.

  • Douglas Robar 3562 posts 4590 karma points MVP 6x admin c-trib
    Sep 21, 2015 @ 10:42
    Douglas Robar
    1

    Make the following changes to the /Views/MacroPartials/ezSearch.cshtml file to resolve this issue.

    Add query.Append("-__NodeTypeAlias:folder "); to exclude all search results associated with a media type (or document type for that matter) that has the name 'folder'. Place it (twice) in the switch (model.IndexType) block as shown below:

        switch (model.IndexType)
        {
            case UmbracoExamine.IndexTypes.Content:
                query.AppendFormat("+({0}) ", contentPathFilter);
                break;
            case UmbracoExamine.IndexTypes.Media:
                query.AppendFormat("+({0}) ", mediaPathFilter);
                query.Append("-__NodeTypeAlias:folder ");
                break;
            default:
                query.AppendFormat("+(({0}) ({1})) ", contentPathFilter, mediaPathFilter);
                query.Append("-__NodeTypeAlias:folder ");
                break;
        }
    

    cheers,
    doug.

  • Ajay Karwal 31 posts 149 karma points
    Sep 21, 2015 @ 10:47
    Ajay Karwal
    0

    Thanks Doug. That's perfect :)

  • Douglas Robar 3562 posts 4590 karma points MVP 6x admin c-trib
    Sep 21, 2015 @ 11:18
    Douglas Robar
    100

    Easier, of course, would be to add the check in the mediaPathFilter variable directly. That way it wouldn't have to be added twice to the code and wouldn't also filter out content with a doctype of 'Folder'.

            var mediaPathFilter = model.RootMediaNodeId > 0
            ? string.Format("__IndexType:{0} +searchPath:{1} -__NodeTypeAlias:folder", UmbracoExamine.IndexTypes.Media, model.RootMediaNodeId)
            : string.Format("__IndexType:{0} -__NodeTypeAlias:folder", UmbracoExamine.IndexTypes.Media);
    
Please Sign in or register to post replies

Write your reply to:

Draft