布尔场上的Aerospike滤波器表达不起作用
我已经在Java写下了以下Aerospike过滤器。 field1
和field2
都是布尔值。由于某种原因,尽管记录与标准匹配,但“ filterbyfield.validboth”条件并不能产生真实。
由于它是布尔值,所以我将1用于true,为false为0。
我想念什么吗?
public Exp getFilterByFieldFilter(FilterByField filterByField) {
if (filterByField == null || "".equals(filterByField)) {
return Exp.val(true);
}
if (filterByField == filterByField.All) {
return Exp.val(true);
} else if (filterByField == filterByField.ValidBoth) {
return Exp.and(Exp.eq(Exp.intBin("Field1"), Exp.val(0)),
Exp.eq(Exp.intBin("Field2"), Exp.val(0)));
}
}
从我可以通过AQL从数据库结果中看到的内容,未设置为true的结果并未反映在结果集中。
我应该写过滤器是检查此情况的另一种方法吗?如果是这样,这种情况会是什么样?
我尝试检查exp.val(null),但出错。
这是通过AQL设置的数据库结果
[
{
"PK": "1",
"Name": "ABC",
"Field1": 1,
"Field2": 1
},
{
"PK": "2",
"Name": "EFG",
"Field1": 1
},
{
"PK": "3",
"Name": "XYZ",
}
]
I've written the following Aerospike filter in Java. Both Field1
and Field2
are booleans. For some reason, the "filterByField.ValidBoth" condition does not yield true, although the record matches the criteria.
Since it's a boolean, I'm using 1 for true and 0 for false.
Am I missing something?
public Exp getFilterByFieldFilter(FilterByField filterByField) {
if (filterByField == null || "".equals(filterByField)) {
return Exp.val(true);
}
if (filterByField == filterByField.All) {
return Exp.val(true);
} else if (filterByField == filterByField.ValidBoth) {
return Exp.and(Exp.eq(Exp.intBin("Field1"), Exp.val(0)),
Exp.eq(Exp.intBin("Field2"), Exp.val(0)));
}
}
From what I can see from database results through AQL, those which are not set to true are not reflected in the result set.
Should I write my filter is a different way to check this condition? If so what would that condition look like?
I tried checking for Exp.val(NULL) but got error.
Here's my database result set through AQL
[
{
"PK": "1",
"Name": "ABC",
"Field1": 1,
"Field2": 1
},
{
"PK": "2",
"Name": "EFG",
"Field1": 1
},
{
"PK": "3",
"Name": "XYZ",
}
]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果bin name field1和field2包含布尔值,则应以这种方式构造您的表达式(无论所需的逻辑是什么):
我测试了下面的构造,似乎对我有用:
有效条件:
无效条件(无field2 bin):
If bin names Field1 and Field2 contain boolean values then your expression should be constructed in this fashion (whatever the desired logic is):
I tested the construct below, seems to work for me:
Valid condition:
Invalid Condition (no Field2 bin):