Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
12-01-2022 02:50 AM
Hello,
I'm using a composite database KB that includes two graphs KB.actors and KB.searches
I need to get information about actors that are in KB.actors graph using ids of actors that are the result of a filtre on KB.searches.
I tried this query:
The query doesn't work "
USE can only appear at the beginning of a (sub-)query "USE geotrend.actors
Is there any way to join data cross a composite database graphs? is it possible to do it?
Thanks,
Solved! Go to Solution.
12-01-2022 07:25 AM - edited 12-01-2022 07:31 AM
Hi,
Thank you for your answers @steve and @glilienfield
Finally the following query worked (inspired from your answers 🙂 ) :
//Query cross databases CALL{ use KB.searches match(n:Company) RETURN n.entityId as id LIMIT 200 } WITH id CALL{ WITH id use KB.actors MATCH(m:Company)-[:ALIAS]->(a:Alias) WHERE m.entityId=id RETURN m,a } RETURN m.entityId,a.term
12-01-2022 04:02 AM
Look into neo4j fabric. It’s only available with enterprise edition. I also looks like neo4j 5.0 improved on its usage.
https://www.markhneedham.com/blog/2020/02/03/neo4j-cross-database-querying-fabric/
12-01-2022 06:38 AM
Hi @amina - given that you used the word "composite" database - sounds like you're already using v5? At any rate, I reached out internally, and got this:
They need to wrap the parts that access the dbs as subqueries. A couple of doc links and an example:
https://neo4j.com/docs/operations-manual/current/composite-databases/queries/
https://neo4j.com/docs/cypher-manual/5/clauses/use/#query-use-syntax-composite
https://neo4j.com/docs/operations-manual/current/tutorial/tutorial-composite-database/
CALL {
USE KB.searches
MATCH(n:Company) WHERE ...
WITH n.entityId as companyId
RETURN companyId
}
CALL {
USE KB.actors
MATCH(n:Company)-[:ALIAS]->(a:Alias)
WHERE n.entityId=companyId
RETURN a
}
RETURN companyId, a.term
12-01-2022 07:25 AM - edited 12-01-2022 07:31 AM
Hi,
Thank you for your answers @steve and @glilienfield
Finally the following query worked (inspired from your answers 🙂 ) :
//Query cross databases CALL{ use KB.searches match(n:Company) RETURN n.entityId as id LIMIT 200 } WITH id CALL{ WITH id use KB.actors MATCH(m:Company)-[:ALIAS]->(a:Alias) WHERE m.entityId=id RETURN m,a } RETURN m.entityId,a.term
All the sessions of the conference are now available online