MongoDB (Deprecated)
These procedures are deprecated in favor of apoc.mongo.* procedures . |
Available Procedures
Qualified Name | Type | Release |
---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Install Dependencies
The Mongo procedures have dependencies on a client library that is not included in the APOC Library.
This dependency is included in apoc-mongodb-dependencies-4.4.0.33.jar, which can be downloaded from the releases page.
Once that file is downloaded, it should be placed in the plugins
directory and the Neo4j Server restarted.
Field description
-
hostorkey
: the MongoDB host in the formatmongodb://<HOST_NAME>:<PORT>
or a url defined into the apoc configapoc.mongodb.myInstance.url=mongodb://<HOST_NAME>:<PORT>
, which can be invoked by simply passingmyInstance
-
db
: the db name -
collection
: the collection name -
query
: query params -
projection
: projection params -
sort
: sort params -
compatibleValues
(false|true): converts MongoDB data types into Neo4j data types -
skip
: num of documents to skip -
limit
: num of documents to limit -
extractReferences
(false|true): if true and a field contains anObjectId
it will include the related document instead of theObjectId
-
objectIdAsMap
(true|false): extract theObjectId
as map -
documents
: the documents to insert -
update
: the updated params
Examples
Following an example that could help to understand the behaviour of extractReferences
, compatibleValues
and objectIdAsMap
:
Given the following collections:
// Product
...
{"_id": ObjectId("product1"), "name": "Product 1", "price": 100}
{"_id": ObjectId("product3"), "name": "Product 2", "price": 200}
{"_id": ObjectId("product3"), "name": "Product 3", "price": 300}
...
// Person
...
{"_id": ObjectId("person"), "name": "Andrea", "bought": [ObjectId("product1"), ObjectId("product3")]}
...
With the extractReferences=true
, compatibleValues=true
and objectIdAsMap=false
:
{
"_id": "person",
"name": "Andrea",
"bought": [
{"_id": "product1", "name": "Product 1", "price": 100},
{"_id": "product3", "name": "Product 3", "price": 300}
]
}
With the extractReferences=true
, compatibleValues=true
and objectIdAsMap=true
:
{
"_id": {
"timestamp": <...>,
"machineIdentifier": <...>,
"processIdentifier": <...>,
"counter": <...>,
},
"name": "Andrea",
"bought": [
{
"_id": {
"timestamp": <...>,
"machineIdentifier": <...>,
"processIdentifier": <...>,
"counter": <...>,
},
"name": "Product 1",
"price": 100
},
{
"_id": {
"timestamp": <...>,
"machineIdentifier": <...>,
"processIdentifier": <...>,
"counter": <...>,
},
"name": "Product 3",
"price": 300
},
]
}
With the extractReferences=false
, compatibleValues=false
and objectIdAsMap=false
:
{
"_id": "person",
"name": "Andrea",
"bought": ["product1", "product3"]
}