Try our conversational search powered by Generative AI!

Question about Count in MultiSearch



How can I send request of count in multisearch?

where, request of count = EPiServer.Find.SearchExtensions.Count()

           Multisearch = EPiServer.Find.IClient.MultiSearch

Any ideas?

Version EPiServer.Find = 8.9

Best Regards

May 26, 2015 15:29


You cannot use .Count() on individual searches in a multisearch request but you can do it on all searches using .Count() instead of .GetResult():

var results = service.MultiSearch<Article>()

                .Search<Article>(x => x.For("Banana"))

                .Search<Article>(x => x.For("Orange"))


I guess however that you want to do a count on just a some of the searches and to do this with minimal overhead you can use .Take(0) on that query and look at .TotalMatching in the result:

var results = service.MultiSearch<Article>()

                .Search<Article>(x => x.For("Banana"))

                .Search<Article>(x => x.For("Orange").Take(0))



This will effectivly be a count query as it won't return any matching documents and only return the number of documents actually matching your query.

May 27, 2015 16:08

Thank you. It is very good answer.

Best Regards.

May 28, 2015 9:00
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.