To clarify:
I've checked the UnifiedSearchHits returned, and I can see that they have Url properties that should be matched by this filter
I mean to say that I've checked the UnifiedSearchHits returned when I remove the x.SearchHitUrl.PrefixCaseInsensitive call - the filter limiting results to PdfFile types is still in place, and works correctly.
Hi Alex,
Have you tried using the AnyWordBeginsWith("/globalassets/publicationfiles/")) instead?
/T
Hi Toni,
Just gave that a try, no joy. Also tried splitting the SearchHitURL by '/' then using Match("publicationfiles") on the string array, no luck.
This would be a lot easier if there was a way to actually poke at the ISearchContent objects in the debugger, but I can't see that this is possible - they only seem to exist in a transient, non-debuggable (at least in VS2012) state. I can see the relevant fields are present and correct on the UnifiedSearchHit objects, but can't cast these back to ISearchContent.
Does anyone have any other suggestions, or alternative approaches which may allow the same functionality?
In case anyone else finds themselves in the same boat,I eventually hit a solution, after EPiServer Support pointed me in the direction of ContentFolders:
var repository = ServiceLocator.Current.GetInstance<IContentRepository>(); var rootFolder = ContentReference.GlobalBlockFolder; var publicationFiles = repository.GetChildren<ContentFolder>(rootFolder).Single<ContentFolder>(x => x.Name == "PublicationFiles"); return search .BoostMatching(x => x.SearchTitle.MatchCaseInsensitive(query), 4) .Filter(x => x.MatchType(typeof(PdfFile)) & ((PdfFile)x).Ancestors().Match(publicationFiles.ContentLink.ID.ToString()) );
Ancestors (which I found just by poking around) generates an array of strings of ContentIDs all the way down to the root node, so this does the trick for any PDF file sitting anywhere under the PublicationFiles folder.
Alex, was looking for the exact same application with Ancestors(). Thanks!
I've recently taken over maintainance of an EPiServer site using UnifiedSearch for two search functions on the site - one for all content within a specific folder (PublicationFiles), and one for all other content. When the site was running EPiServer 7.1, this was working with the following filters:
Shown here is the filter that only returned results from the top-level SitePublicationFiles folder - there is a corresponding filter that simply returns everything other than the contents of this folder!
However, since moving to the EPiServer 7.5+ world (CMS 7.16.1 and Find 8.10.0.1509 at present) this top level folder has been migrated into the new shared Block/Media directory structure, and now resides in ~/globalassets/publicationfiles/. I also understand that a lot of UnifiedFile functionality has been quietly deprecated (although I have struggled to find documentation for this, and VisualStudio throws no obsolete/deprecated warnings). The net result is that these filters no longer work at all - one returns everything, the other returns nothing!
I've reworked our searches to use new classes based on MediaData in place of UnifiedFile, but I'm struggling to find a replacement for this filtering-by-folder functionality. I had thought that I could use the following to filter based on the relative URL:
(Note that I'm only interested in PdfFiles from this directory. PdfFile here is a class that inherits from MediaData)
However, this returns no results. I've checked the UnifiedSearchHits returned, and I can see that they have Url properties that should be matched by this filter, so I'm not sure why, and it doesn't seem possible to debug 'inside' the filter. Other attempted filters include:
This also doesn't work.
Is there any known way I can reliably filter based on content location, either URL or folder name within the EPiServer Blocks/Media directory structure?