ArangoDB 查询一定数量的数组匹配项

ArangoDB Query for a certain number of matches to an Array

在 ArangoDB 中,我有一个文档,其中包含用于存储 "tokens" 的字段。令牌是一个 int 值数组。例如:

token:
[0] = 5000
[1] = 250
[2] = 300
etc... 

一个令牌最多可以有大约 50 个这样的值。我想查询至少有 4 个与我的 ArrayList 相同的标记的文档。例如,如果我有一个包含以下值的 ArrayList:

[0] = 1;
[1] = 200;
[2] = 400;
[4] = 600;
[5] = 570;

我会得到一个文档列表,这些文档至少有四个与我的数组相同的标记值。目前我正在做:

String query = "FOR doc IN docs LET contained = (FOR token IN @tokenValues FILTER token IN doc.tokens[*]) FILTER LENGTH(contained) > 0 RETURN doc";
            bindVars = new MapBuilder().put("tokenValues", tokenArray).get();

然后我得到至少有 1 个共同标记的文档,并在所有这些文档中搜索至少有 4 个共同标记的文档。我想有一种方法只能获得至少有 4 个共同点的结果,但我似乎无法弄清楚如何去做。

我认为以下 AQL 查询可以做到:

FOR doc IN docs 
  LET contained = (
    FOR token IN doc.tokens 
      FILTER token IN @tokens 
      RETURN token
    ) 
  FILTER LENGTH(contained) >= 4 
  RETURN doc