How to use Find to search both cms pages and products in one request

Vote:
 

Hi, 

I would like to search both cms pages e.g. standpages and commerce products, categories in one request 

I tried to use the following solution but it seems not working correctly and I have problem with the value of totalmatching. 

...

multiSearch = searchClient.Search<ContentData>().For(query).FilterForVisitor(currentLanguage).Skip(skip).Take(itemsPerPage).Track().GetContentResult();

foreach (var item in multiSearch)
{
if (item is Article)
{var article = ((Article)item);

....}

else if (item is Category)
{
var category = ((Category)item);

...}

else if (item is SitePageData)
{ var pageData = ((SitePageData)item);

...}

Any suggestions guys?

Thanks, 

ChiChing

#199633
Edited, Dec 04, 2018 10:12
Vote:
 

Hi Jeroen, 

Thanks for the link!

Did you use something like this?

results = service.MultiSearch<ContentData>()
                .Search<Article>(x => x.For(query))
                .Search<Category>(x => x.For(query))
                .GetResult();
#199642
Dec 04, 2018 11:20
Vote:
 

I actually used this: https://github.com/BVNetwork/DynamicMultiSearch

But I guess you could do it like you do, or maybe use

service.MultiSearch<IContent>()
#199651
Dec 04, 2018 12:46
Vote:
 

I will check the suggestions that Jeroen and Quan provided. 

Thanks!

#199721
Dec 07, 2018 11:41
* 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.