我正在尝试做一个简单的查询,我想在哪里:

select * from POC where Account_No = [accountno] and BUSINESS_UNIT = [business_unit]

以下是我所没有的运气。有任何想法吗?
var filters = new List<FilterContainer>();

filters.Add(new FilterDescriptor<poc>().Bool(b => b.Must(m => m.Term(i => i.Account_No, txtAccount.Text))));
filters.Add(new FilterDescriptor<poc>().Bool(b => b.Must(m => m.Term(i => i.BUSINESS_UNIT, txtBU.Text))));

var searchDescriptor = new SearchDescriptor<poc>();
// Filter with AND operator
searchDescriptor.Filter(f => f.And(filters.ToArray()));

var r = client.Search<poc>(searchDescriptor);

更新

第二个过滤器似乎不起作用。
运行此程序时,我不确定没有记录。我在查看帐户查询时运行记录时看到了它
{
  "query": {
    "term": {
      "BUSINESS_UNIT": "CSPCN"
    }
  }
}

最佳答案

这应该做您想要的:

FilterContainer filter = null;

filter &= Filter<poc>.Term(i => i.Account_No, txtAccount.Text);
filter &= Filter<poc>.Term(i => i.BUSINESS_UNIT, txtBU.Text);

var r = client.Search<poc>(sd => sd.Filter(f => filter));

10-06 10:50