Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
01-22-2021 10:28 AM
The documents in m MongoDB have a _id of type ObjectId. In Neo4j a node has a reference to the document by the ObjectId as a string representation. But i can´t figure out how to query a document by the ObjectId as a string using apoc.mongodb.
Neo4j 4.2.1 community and APOC (+ mongodb driver) 4.2.0
This obviously does not work:
CALL apoc.mongodb.find("mongodb://host:port", "testdb", "testcoll", {_id: "6005c050d36d9acd28b8679b"}, null, null)
CALL apoc.mongodb.find("mongodb://host:port", "testdb", "testcoll", {_id: ObjectId("6005c050d36d9acd28b8679b")}, null, null)
01-25-2021 01:50 AM
@enstricht thank you for reaching us now is not possible get the document by Object id value, I opened an issue in order to add a new feature ASAP:
Thank you so much for pointing this out!
01-25-2021 11:15 AM
@enstricht I created the new procedure, awaiting approval, apoc.mongodb.get.byObjectId(<host>,<db>,<collection>,<objectIdAsString>, <fieldValue: default='_id'>, <optionalConfigMap>)
.
For example, to get a document with object id, you can type CALL apoc.mongodb.find("mongodb://host:port", "testdb", "testcoll", "6005c050d36d9acd28b8679b")
.
In optionalConfigMap you can put compatibleValues
(to convert MongoDB data types into Neo4j data types, with default true
), extractReferences
(it will include the related document instead of the ObjectId, default: false
).
Unfortunately I cannot attach the .jar with this new procedure, because it is not a supported format.
All the sessions of the conference are now available online