I am having a problem querying ArangoDB in java for a value of Arrays. I have tried with both String[] and ArrayList, both with no success.
My query:
FOR document IN documents FILTER @categoriesArray IN document.categories[*].title RETURN document
BindParams:
Map<String, Object> bindVars = new MapBuilder().put("categoriesArray", categoriesArray).get();
categoriesArray
contains a bunch of Strings. I'm not sure why it isn't returning any results, because if I query using:
FOR document IN documents FILTER "Politics" IN document.categories[*].title RETURN document
I get the results I am looking for. Just not when using an Array or ArrayList.
I also tried querying for:
FOR document IN documents FILTER ["Politics","Law] IN document.categories[*].title RETURN document
in order to emulate an ArrayList, but this doesn't return any results. I would query using a bunch of individual Strings, but there are too many and I get an error from the Java driver when querying with a String that long. Thus, I must query using an Array or ArrayList.
An example of the categoriesArray:
["Politics", "Law", "Nature"]
A sample image of the database:
LET categories = ["Politics", "Law"]
,LET cat_length = LENGTH(categories)
&FILTER cat_length == LENGTH(INTERSECTION(categories, document.categories[*].title))
? Code looks cleaner, but dunno about performance and memory-consumption. Or is it possible to add support for Sets in AQL? LikeFILTER SET(["Politics", "Law"]) IN SET(document.categories[*].title)
. Or in JS, one can do:let arr = ["Law", "Science", "Politics"]; ["Politics","Law"].every(elem => arr.indexOf(elem) != -1)
. How aboutEVERY()
andSOME()
in AQL?SOME(["Law","Politics"], doc.categories[*].title))
– Witch