1

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)
4
  • 2
    Can you try the following: bindVars = new MapBuilder().put("now", now).put("categories", categories).put("tags", tags).put("locations", locations).get(); Commented Jan 10, 2015 at 7:06
  • 2
    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. Commented Jan 10, 2015 at 7:09
  • Thank you for your solution, can you post a quick answer so that I may give you proper credit? Commented Jan 10, 2015 at 20:17
  • @Jgolden1 can you also check this answer as accepted? ;-) Commented Mar 17, 2016 at 17:35

1 Answer 1

4

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();
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.