Virtual Happy Hour this month, Jun 28, we'll be getting a sneak preview at our soon to launch SaaS CMS!

Try our conversational search powered by Generative AI!

Filtering issue with Find


Dear experts,

I am using CMS 6 R2 compatible version of Find. I want a functionality in find filters similar to string contain functionality.

I have the following data under Find Index overview for VPP folders 

 "VirtualPath$$string": "/Documents/White paperss/AlloyMeet.pdf",
 "VirtualPath$$string": "/Documents/White paperss/AlloyPlan.pdf",
 "VirtualPath$$string": "/Documents/White paperss/AlloyTrack.pdf",

I have a simple list called "ExcludeFolders" which I need to use for a filter.:- 

  static IList ExcludeFolders = new List            { "/Documents/", "/Accounts/" };

I am using a filter to exlude 

if (ExcludeFolders.Count > 0)
foreach (var excludeFolders in ExcludeFolders)

filterForFolders = filterForFolders.And( x => (!x.MatchTypeHierarchy(typeof(UnifiedFile)) | !((UnifiedFile)x).VirtualPath.Match( excludeFolders)));

query = query.Filter(filterForFolders);

The above query is correct and giving me results only if the string values in my excludefolders list exactly match to the virtual path string. I uderstand this is the default functionality for Match.

However I want my filter to work like a "Contains" string function. i.e it should only look for certain words not the whole string and if it contains it, give me the result. But if I use that in above code !((UnifiedFile)x).VirtualPath.Contains( excludeFolders))); It starts complaining you cannot apply a filter to type bool. That means I need to use onl filter type method

Can I achieve the results using any existing filters of Episerver find?I would appreciate if I can get a sample example. .

Many thanks,

Nov 29, 2014 13:24
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.