elasticsearch NEST 不包含指定关键词数组集合精确过滤,后加其他过滤条件​


elasticsearch 不包含指定关键词精确过滤,后加其他过滤条件


ES Code:

GET order/list/_search
{
  "size": 10, 
  "query": {
    "bool": {
      "must_not": [
        {
          "bool": {
            "should": [
              {
                "terms": {
                  "order": [
                      "iphone","","iphone4","iphone5","iphone5c"
                  ]
                }
              }
            ]
          }
        }
      ],
      "must": [
        {
          "range": {
            "date": {
              "gte": "2014-01-02",
              "lte": "2015-12-01"
            }
          }
        }
      ]
   }
  },
  "sort": [
    {
      "date": {
        "order": "desc"
      }
    }
  ]
}

NEST Code:

// findArrList = string[] {"iphone","iphone4" ...}
                         query &=   q.Bool(
                                    k => k.MustNot(
                                        p => p.Bool(
                                            l => l.Should(
                                                f => f.Terms(
                                                    oq => oq.order, findArrList //order 需要过滤的字段
                                                    )
                                                    )
                                                )
                                            )
                                    );


谢谢

posted @ 2016-01-27 20:16  游子善心  阅读(1)  评论(0编辑  收藏  举报  来源