首页 > 解决方案 > 查询多个集合 Arangodb

问题描述

FOR col_name IN ['col_1', 'col_2']

FOR d IN FULLTEXT(col_name, 'label', @value)

RETURN d

不工作

FOR d IN FULLTEXT('col_1', 'label', @value)

RETURN d

工作正常

我正在使用 arango 3.4.2-1

标签: arangodbaql

解决方案


in general you can query two collections like this:

FOR col1doc IN col_1
  FILTER col1doc.foo == 'bar'
    FOR col2doc IN col_2
      FILTER col1doc.joinfield == col2doc.joinfield
RETURN {col1doc: col1doc, col2doc: col2doc} 

as its documented in the AQL manual for joins

Please note that simple string equalities can be done using FILTERs and don't need fulltext indices.

To the old fulltext index for two collections you can use subqueries like this:

let col1Documents = (FULLTEXT(col_1, 'label', @value))
let col2Documents = (FULLTEXT(col_2, 'label', @value))

RETURN CONCAT(col1Documents, col2Documents)

The more modern way to achieve this would be to use ArangoSearch views which can handle numerous collections.


推荐阅读