elasticsearch nest 数组包含查询

// es 查询语句
GET index1/order/_search
    {
  "query": {
    "bool": {
      "must": [
        {
          "range": {
            "date": {
              "gte": "2015-01-01T00:00:00.000",
              "lte": "2016-01-01T00:00:00.000"
            }
          }
        },
        {
          "bool": {
            "should": [
              {
                "terms": {
                  "phone": [
                    "iphone4",
                    "vivo",
                    "huawei phone"
                  ]
                }
              }
            ]
          }
        }
      ]
    }
  }
}
// nest 对应语句
client.Search<order>
                (s => s
                        .From(0)
                        .Size(10)
                        .Query(q =>q.Filtered(p=>p.Query(t=>t
                                    .Bool(q1=>q1
                                        .Should(h=>h
                                            .Terms(oq=>oq
                                                .Order, ["iphon4","vivo","huawei"])
                                        ))
                                    ));


测试有效


posted @ 2016-01-21 18:14  游子善心  阅读(4)  评论(0编辑  收藏  举报  来源