1
votes

I am using the ArangoDB java driver and am trying to query for documents containing one of a number of Strings, which are stored in the arangoDB documents in lists. I am using ArrayList with a list of Strings in the query.

Query:

FOR document IN documents FILTER ( @now - document.dateAdded < 2592000000 ) && 
(document.categories IN @categories || document.tags IN @tags 
|| document.locations IN @locations ) RETURN document

Map<String, Object> bindVars = new MapBuilder().put("now", now).put("categories", categories).put("@tags", tags).put("@locations", locations).get();

"now" contains a long. All the others are ArrayList<String>. This is throwing an error explaining that "bind parameter '@tags' has an invalid value or type". Since this ArrayList is no different than the others, my only theory is that I am inputting the logic incorrectly. How does one query for:

FunctionCondition1 AND (condition2 OR condition3 OR condition4)
1
Can you try the following: bindVars = new MapBuilder().put("now", now).put("categories", categories).put("tags", tags).put("locations", locations).get(); - fceller
The bind vars are marked in the query using "@", but the are given without the first '@'. A collection parameter is specified with two at as "@@myvariablecollection'. In the case the bind var is '@myvariablecollection' and must be of type collection. - fceller
Thank you for your solution, can you post a quick answer so that I may give you proper credit? - JosephG
@Jgolden1 can you also check this answer as accepted? ;-) - dothebart

1 Answers

4
votes

The bind vars are marked in the query using '@', but they are given without the first '@'. A collection parameter is specified with two at symbols @@ as @@myvariablecollection. In this case the bind var is @myvariablecollection and must be of type collection.

For example:

FOR a IN @@collection FILTER a.x == @now RETURN a

requires the bind variables to be given as @collection and now where @collection must name a collection and now should be (in this example) a number.

Map<String, Object> bindVars = new MapBuilder().put("@collection", "myCollection").put("now", 1234).get();