Guest User

Untitled

a guest
Oct 18th, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. TermsAggregation topTermAgg = null;
  2. TermsAggregation currentAgg = null;
  3. foreach (var pivotName in activePivots)
  4. {
  5. newTermAgg = new TermsAggregation("pivot")
  6. {
  7. Field = pivot.ToString().ToLower()
  8. };
  9.  
  10. if (topTermAgg == null)
  11. {
  12. topTermAgg = newTermAgg;
  13. }
  14. else
  15. {
  16. currentAgg.Aggregations = newTermAgg;
  17. }
  18. currentAgg = newTermAgg;
  19. }
  20.  
  21. var searchRequest = new SearchRequest(Indices.Index("a", "b", "c"))
  22. {
  23. Size = 0,
  24. Aggregations = topTermAgg,
  25. Query = query,
  26. };
  27.  
  28. {
  29. "size": 0,
  30. "query": {
  31. "bool": <Fairly complex query, that works fine. It's the aggregation that has the problem.>
  32. },
  33. "aggs": {
  34. "pivot": {
  35. "terms": {
  36. "field": "pivot1"
  37. },
  38. "aggs": {
  39. "pivot": {
  40. "terms": {
  41. "field": "pivot2"
  42. }
  43. }
  44. }
  45. }
  46. }
  47. }
Add Comment
Please, Sign In to add comment