November Happy Hour will be moved to Thursday December 5th.

Multiple searches in one request

Vote:
 

I want to use Episerver Find MultiSearch to limit nr of requests to Find, as specified here

How can I dynamically add Searches, typically inside a foreach statement?

The code below works, but I can see through Fiddler that nr of request matches 'mainCategories' count.

if (mainCategories.Any())
 {
     var multiSearchQuery = SearchClient.Instance.MultiSearch<EntryContentBase>();
     foreach (var mainCategory in mainCategories)
     {
        var mainCategoryName = mainCategory.Term;
        multiSearchQuery.Searches.Add(
                multiSearchQuery.Client.Search<EntryContentBase>()
                     .CommonProductFilter(currentStore)
                     .AddPromotionPrefixAndStoreFilter(prefix, currentStore)
                     .Filter(p => p.MainCategory().Match(mainCategoryName))
                     .Take(count));
     }
                
     var contentResults = multiSearchQuery.GetContentResult();
     
}
#215972
Edited, Jan 21, 2020 8:57
Vote:
 

Same result if I do this:

if (mainCategories.Any())
 {
     var multiSearchQuery = SearchClient.Instance.MultiSearch<EntryContentBase>();
     foreach (var mainCategory in mainCategories)
     {
        var mainCategoryName = mainCategory.Term;
        multiSearchQuery.Search<EntryContentBase>(
                m => m.CommonProductFilter(currentStore)
                     .AddPromotionPrefixAndStoreFilter(prefix, currentStore)
                     .Filter(p => p.MainCategory().Match(mainCategoryName))
                     .Take(count));
     }
                
     var contentResults = multiSearchQuery.GetContentResult();
     
}
#215973
Jan 21, 2020 9:53
Vote:
 

Update: this has been handed over to the support team - seems like a bug.

#216368
Feb 05, 2020 7:24
Vote:
 

Preferably you should use the second approach (simply since you then can avoid having to type the .Search request and just use .Search()). In our test setup we use a similar test setup to verify that it only makes 1 request, so atm I'm not able to reproduce the issue.
As for the fiddler requests you see, are you seeing multiple _msearch requests?

#219669
Apr 01, 2020 7:59
Vote:
 

I am running Commerce 13.16.0. 

In Fiddler I see one _msearch request and x number of _search requests (x = nr of categories).

#219670
Apr 01, 2020 8:47
Vote:
 

Some suggestions you can test: The custom filters you are adding does not trigger a search request (what if yoy remove them)? Are the _search requests before or after the _msearch request? If you not execute the msearch-request, do you still see the _search requests?

#223115
May 19, 2020 9:39
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* 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.