Facets and hits?

Vote:
 

Hi, my Find skills are a bit limited, so I hope someone can push me in the right direction. 

Lets say I have a query that gets all "Categories":

var searchResults = client.Search()
    .TermsFacetFor(x => x.Category)
    .Take(0)
    .GetResult();

If I now want the 10 first hits in each Facet, can I extend my query to do that? Or do I need to write a subquery for each Facet?

Thanks,
Erik

#139907
Oct 09, 2015 13:22
Vote:
 

Sorry, didn't read the thread completly, removed my wrong answer

#139912
Edited, Oct 09, 2015 14:31
Vote:
 

If you need to get the 10 first (order by something?) for X amount of facets, I don't think there is a way to do it in a single query.
However, you could use multisearch to limit the number of queries. Here's an example:

                var words = new List<string>() { "burger", "banjo", "water"};
                var multiSearchQuery = SearchClient.Instance.MultiSearch<MyItem>();            
                foreach (var word in words)
                {
                   multiSearchQuery = multiSearchQuery.Search(x => x.Filter(z => z.Category.Match(word)));

                }
                multiSearchQuery.GetResult();
#139913
Edited, Oct 09, 2015 14:35
Vote:
 

Thanks, I'll give it a try.

#139921
Oct 09, 2015 15:49
Vote:
 

Keep in mind that multisearch has a maximum of 10 queries, so if you go above that you'll have to modify your code to create more multisearch queries.

If that is the case, I suppose Henrik's answer is helpful, as that means that you'll need to get more than 10 facets, which is the default value :-)

TermsFacetFor(x => x.Something, facet => facet.Size = 50)
#139923
Oct 09, 2015 15:55
Vote:
 

So I gave it a try and it works. Feels a bit dirty though.. :) A question though. If I add 10 searches to a multisearch, I get 403 forbidden, saying that 10 is the maximum allowed queries. If I only add 9 queries it works. Is this by design? Or just a misstake?

#139950
Oct 12, 2015 11:10
Vote:
 

Sounds like a bug to me

#140244
Oct 14, 2015 10:02
* 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.