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:
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.
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.
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).
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:
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'.
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:
cheers,
doug.
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
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.
No, that makes sense.
I think it should just be a case of adding:
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
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.
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.
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 theswitch (model.IndexType)
block as shown below:cheers,
doug.
Thanks Doug. That's perfect :)
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'.is working on a reply...