1

就像下面的http请求:基于TERM“service_project”aggr,还有2个SUM aggr“service_hour_price”和“servic_part_price”。我可以使用 Elasticsearch Nest 做同样的事情吗?

      "aggs": {
        "3": {
          "terms": {
            "field": "service_project",
            "size": 50,
            "order": {
              "1": "desc"
            }
          },
          "aggs": {
            "1": {
              "sum": {
                "field": "service_hour_price"
              }
            },
            "2": {
              "sum": {
                "field": "servic_part_price"
              }
            }
          }
        }
    }

现在我只能使用基于 That Term Aggr 的一个 SUM Aggr,如下所示:

                return s.Aggregations(a => a
                .Terms("names", st => st
                    .Field(o => o.service_project)
                    .OrderDescending("sum")
                    .Size(term_count)
                    .Aggregations(aa => aa
                        .Sum("sum", m => m
                            .Field(o => o.service_hour_price)))));
4

1 回答 1

0

你快到了:

s.Aggregations(a => a
    .Terms("3", t => t
        .Field("service_project")
        .Size(50)
        .OrderDescending("1")
        .Aggregations(aa => aa
            .Sum("1", sum => sum.Field("service_hour_price"))
            .Sum("2", sum => sum.Field("service_part_price")))
    ));

希望能帮助到你。

于 2015-11-17T19:29:09.530 回答