【发布时间】:2018-02-03 07:05:27
【问题描述】:
我想知道我们是否可以在从弹性搜索中获取数据的同时编写条件表达式。
例如 - 我拥有的记录中有一个列。该列具有从 1 到 100 的整数值。我想获取该列具有偶数值的所有此类记录。目前,我正在这样做,构建一个我想要的值列表,然后将它们传递给 TermsQuery :
for(int i = 1; i <= 100; i++)
{
if (i%2 == 0)
possibleMatches.Add(i);
}
Func<TermsQueryDescriptor<MyClass>, ITermsQuery> TermsQuery = t =>
{
return t.Field(f => f.MyColumn).Terms(possibleMatches);
};
var results = collection.Search(s =>
s.Index(MyIndex).Type(MyElasticsearchType)
.Query(qu=>qu.Terms(TermsQuery));
是否可以在术语查询或其他查询类型中编写条件表达式?说类似
t.Field(f=> f.MyColumn%2 == 0)
【问题讨论】:
标签: c# .net elasticsearch nest