一般来说,你不能。
在此 API 中,您只能否定原子条件,将 ~gt~ 更改为 ~lte~ 等,例如。 G。将open_price~gt~10 更改为open_price~lte~10。
但是你不能在这个 API 中否定非原子条件,特别是你不能使用德摩根定律。
n 个变量的布尔函数只有 3n (+1) 个布尔函数,可以使用合取和原子否定来表示。 n 个变量的布尔函数总数为 22ⁿ。顺便说一句,它们都可以使用合取和非原子否定来表达。因此,存在无法使用合取和原子否定来表达的布尔函数。
您应该发出两个或更多请求,然后在 API 客户端上合并结果。
有几种方法可以做到这一点,它们在请求数量、检索的记录总数(某些记录可能被检索多次)和所需的 API 调用信用(它等于条件的数量)方面有所不同。
假设原始数据如下所示(让我们跳过open_price 属性)。
{
{
"identifier": "A-OK",
"current_volume": 1000002, "average_volume": 1000001
},
{
"identifier": "B-OK",
"current_volume": 1000001, "average_volume": 999999
},
{
"identifier": "D-OK",
"current_volume": 999999, "average_volume": 999998
},
{
"identifier": "E-OK",
"current_volume": 1000001, "average_volume": 1000002
},
{
"identifier": "G-NO",
"current_volume": 999999, "average_volume": 1000001
},
{
"identifier": "H-NO",
"current_volume": 999998, "average_volume": 999999
}
}
您需要检索标识符为 A-OK、B-OK、D-OK、E-OK 的记录。
方法一(两个请求,结果集不相交)
current_volume~gt~1000000
current_volume~gt~average_volume
如您所见,我们只是在客户端上执行析取,而不是在服务器上...
方法2(三个请求,结果集不相交)
current_volume~gt~1000000,current_volume~gt~average_volume
current_volume~gt~1000000,current_volume~lte~average_volume
current_volume~lte~1000000,current_volume~gt~average_volume
在这种方法中,我们依赖于这个事实:A||B 等于 (A && B) ^^ (A && !B) ^^ (!A && B)。
方法3(两个请求,结果集不相交)
current_volume~gt~1000000
current_volume~lte~1000000,current_volume~gt~average_volume
在这种方法中,我们依赖于这个事实:A||B 等于 A ^^ (!A && B)。
方法4(两个请求,结果集不相交)
在您的特定情况下,存在一种依赖于实数顺序关系的传递性的方法。
average_volume~gt~1000000,current_volume~gt~1000000
average_volume~lte~1000000,current_volume~gt~average_volume
但是,这种方法在 API 调用信用方面并没有带来多少利润。
比较
+----------+----------+-----------+--------------+----------+
| Approach | Number of| Records | Resultsets | Total |
| | requests | retrieved | disjointness | credits |
+----------+----------+-----------+--------------+----------+
| # 1 | 2 | 6 (3+3) | no | 2 |
| # 2 | 3 | 4 | yes | 6 |
| # 3 | 2 | 4 | yes | 3 |
| # 4 | 2 | 4 | yes | 4 |
+----------+----------+-----------+--------------+----------+