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

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

RETURN d

does not works

but

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

RETURN d

works fine

I am using arango 3.4.2-1

1 Answer 1

4

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for this! This works fine but if there is no data in collection 2, nothing is returned, even though collection 1 has data. How do I get the fields from col1doc to return even if col2doc has no data?

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.