SaaS CMS has officially launched! Learn more now.

Filter pages that implement an interface and a Boolean is set to true

Vote:
 

Hi guys,

I have an existing search that uses the unified search and I have added an iterface to a few page models that exposed a boolean property. I want the unified search to filter to show only types implementing this interface where the boolean is true. Can I do this without having to have 2 search methind one to unifieid and one to Search?

Thanks, Scott

#179247
Jun 06, 2017 17:38
Vote:
 

Yup. You can simple use Filter<T>:

.Filter<YourInterface>(x => x.YourBool.Match(true))
#179253
Jun 06, 2017 20:09
Vote:
 

The doesn't seem to work as the unified search is ISearchContent and can't convert the type to my interface or any of the model types. 

I've tried a driect cast .Filter(x => ((SitePage) x).IsVideoPage.Match(true)); which isn't erroring but it's also not matching on true values. 

#179271
Jun 07, 2017 10:14
Vote:
 

The object casts never actually happens when the code is executed. The way the Find API works, it will only look at the property name, and then pass that on to the rest api. 
So it should work to use the Filter<T>. It should also work with the direct cast. Could you post your complete query?

#179275
Jun 07, 2017 10:40
* 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.