我在 java 中查询 ArangoDB 以获取数组值时遇到问题。我尝试过使用 String[] 和 ArrayList,都没有成功。
我的查询:
FOR document IN documents FILTER @categoriesArray IN document.categories[*].title RETURN document
绑定参数:
Map<String, Object> bindVars = new MapBuilder().put("categoriesArray", categoriesArray).get();
categoriesArray
包含一堆字符串。我不确定为什么它没有返回任何结果,因为如果我使用以下方式查询:
FOR document IN documents FILTER "Politics" IN document.categories[*].title RETURN document
我得到了我正在寻找的结果。只是在使用 Array 或 ArrayList 时不会。
我还尝试查询:
FOR document IN documents FILTER ["Politics","Law] IN document.categories[*].title RETURN document
为了模拟 ArrayList,但这不会返回任何结果。我会使用一堆单独的字符串进行查询,但是太多了,当使用这么长的字符串进行查询时,Java 驱动程序会出错。因此,我必须使用 Array 或 ArrayList 进行查询。
类别数组的示例:
["Politics", "Law", "Nature"]
数据库的示例图像: