首页 文章

ArangoDB查询多个OR?

提问于
浏览
1

我正在使用ArangoDB java驱动程序,并且我正在尝试查询包含多个字符串之一的文档,这些字符串存储在列表中的arangoDB文档中 . 我在查询中使用带有字符串列表的ArrayList .

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"包含很长时间 . 所有其他人都是 ArrayList<String>. 这是一个错误解释“ bind parameter '@tags' has an invalid value or type ” . 由于这个ArrayList与其他ArrayList没什么不同,我唯一的理论是我输错的逻辑 . 如何查询:

FunctionCondition1 AND (condition2 OR condition3 OR condition4)

1 回答

  • 4

    使用 '@' 在查询中标记绑定变量,但是它们没有第一个 '@' . 集合参数指定为两个符号 @@@@myvariablecollection . 在这种情况下,绑定var是 @myvariablecollection ,并且必须是类型集合 .

    例如:

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

    要求绑定变量为 @collectionnow ,其中 @collection 必须为集合命名, now 应该是(在此示例中)数字 .

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

相关问题