如何在Elasticsarch中为Mutliterm子句编写Nest Query

时间:2019-06-30 01:24:13

标签: elasticsearch multi-term

我正在尝试将以下Elasticearch v.6.5查询写入NEST V6.8。

GET staff/_search
{
  "size": 0, 
"aggregations" : {
    "groupby" : {
      "composite" : {
        "size" : 1000,
        "sources" : [
          {
            "437" : {
              "terms" : {
                "field" : "id.keyword",
                "missing_bucket" : true,
                "order" : "asc"
              }
            }
          },
          {
            "439" : {
              "terms" : {
                "field" : "salary",
                "missing_bucket" : true,
                "order" : "asc"
              }
            }
          }
        ]
      }
    }
  }
}

对于以下内容,我正在编写以下NEST查询

    var result = _connection.Search<staff>(Id => Id.Index("staff").Size(0)
    .Aggregations(a => a.Composite("groupBy",
                    c => c.Sources(s =>
                                   s.Terms("id", t => 
                                   t.Field(f => f.id.Suffix("keyword"))
                                   &&
                                   s.Terms("id", t =>
                                   t.Field(f => f.salary)
                                   )
                                  )
                                )
                 )
        );

获取错误: 运算符“ &&”不能应用于类型为termsCompositeAggregationSourceDescriptor和CompositeAggregationSourceDescriptor的操作数

我们非常感谢您的帮助

0 个答案:

没有答案