apoc.mongodb.count

Procedure APOC Full Deprecated

apoc.mongodb.count(host-or-key,db,collection,query) yield value - perform a find operation on mongodb collection

Signature

apoc.mongodb.count(host :: STRING?, db :: STRING?, collection :: STRING?, query :: MAP?) :: (value :: INTEGER?)

Input parameters

Name Type Default

host

STRING?

null

db

STRING?

null

collection

STRING?

null

query

MAP?

null

Output parameters

Name Type

value

INTEGER?

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.3.0.12.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.

Alternatively, you could copy these jars into the plugins directory:

  • bson-3.4.2.jar

  • mongo-java-driver-3.4.2.jar,

  • mongodb-driver-3.4.2.jar

  • mongodb-driver-core-3.4.2.jar

You should be able to get them from the following links:

Usage Examples

The examples in this section are based on a Mongo DB instance with a pre-populate twitter dataset. You can find instructions for setting this up at github.com/neo4j-examples/mongo-example.

Cypher
CALL apoc.mongodb.count('mongodb://mongo:neo4j@mongo:27017', 'test', 'tweets', {});
Table 1. Results
value

966