Advertisement
Guest User

Untitled

a guest
Jan 12th, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. var response = Client.Search<myclass>(s => s
  2. .Type("type")
  3. .Aggregations(a => a
  4. .Terms("code_bucket", t => t
  5. .Field("field_of_aggregation")
  6. .Size(30)
  7. .Order(TermsOrder.CountAscending)
  8. .Aggregations(a2 => a2
  9. .TopHits("code_bucket_top_hits", th => th.Size(20))
  10. )
  11. )));
  12.  
  13. var firstBucket= response.Aggs.Terms("code_bucket");
  14. foreach (var bucket in firstBucket.Buckets)
  15. {
  16. var hits = bucket.TopHits("code_bucket_top_hits");
  17. foreach (var hit in hits.Documents<myclass>())
  18. {
  19. var prop1= hit.prop1;
  20. var prop2= hit.prop2;
  21. }
  22. }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement