I have a product page where I list products and facets for filtering based on size and color.
Is there a way to get products and facets in one roundtrip to the Find server (using multisearch or other)?The objects returned (List and Dictionary>) are quite different so using multi search with projection to same type is a bit hairy.
Note: Since I'm always displaying all facets (facets from original listing) including the facets as part of current query is not an option.
Is this possible to do without two queries/roundtrips to the server?
Perhaps by combining MultiSearch with Tuple? Something like
client.Instance.MultiSearch<Tuple<List<Product>, Dictionary<string, List<string>>>>()
and then populate the List<Product> in the first search, and populating the Dictionary<string, List<string>> in the second search?
I've never tried this though :-)
I like your thinking. I will try ;)
How do you query for the facet?
Sorry if I misunderstand your question but I don't understand why your facet query would return Dictionary<string, List<string>> and not SearchResults<Product> (where you later fetch the facet using .XXXFacetFor()).
If you 'list' query and 'facet' query are both .Search<Product> with no later projections then they both return the same result type and you should be able to execute them in the same multisearch request./Henrik
I was under the impression that the problem was to do a multisearch without having to use a common projection, but maybe I'm wrong? Anyway, I found that a bit interesting, so I wrote a little bit of code. Maybe it could be of use? https://github.com/BVNetwork/EPiCode.DynamicMultiSearch
@Henrik and @Per Magne: I want to avoid common projection - the result sets are quite different (products, pages and articles). And I want to limit the number of round trips to the server.
At the moment I'm playing around with your code, @Per Magne. It looks very promising, I just need to make sure that all features I need are supported; such as facets and paging within each search result. Nice work, PM ;)
Great! Keep me posted