Index: /other-projects/maori-lang-detection/src/org/greenstone/atea/MongoDBAccess.java
===================================================================
--- /other-projects/maori-lang-detection/src/org/greenstone/atea/MongoDBAccess.java	(revision 33878)
+++ /other-projects/maori-lang-detection/src/org/greenstone/atea/MongoDBAccess.java	(revision 33879)
@@ -352,8 +352,20 @@
 
     /**
+       RUNNING A MONGODB COLLECTION.AGGREGATE() in JAVA:
+
+       https://stackoverflow.com/questions/31643109/mongodb-aggregation-with-java-driver
+       https://stackoverflow.com/questions/48000891/parse-mongodb-json-query-in-java-with-multiple-criteria
+       Not Java: https://stackoverflow.com/questions/39060221/a-pipeline-stage-specification-object-must-contain-exactly-one-field-with-php-mo
+
+       (https://stackoverflow.com/questions/55029222/parse-mongodb-query-to-java)
+       https://www.programcreek.com/java-api-examples/?api=com.mongodb.client.model.Aggregates
+       On using group(TExpression) inside collection.aggregate().
+
+       
+       The aggregate() we want to run:
 
        db.Websites.aggregate([
-    {
-        $match: {
+       {
+         $match: {
             $and: [
                 {geoLocationCountryCode: {$ne: "NZ"}},
@@ -362,24 +374,17 @@
                 {$or: [{geoLocationCountryCode: "AU"}, {urlContainsLangCodeInPath: false}]}            
             ]
-        }
-    },
-    { $unwind: "$geoLocationCountryCode" },
-    {
-        $group: {
+	  }
+	},
+	{ $unwind: "$geoLocationCountryCode" },
+	{
+          $group: {
             _id: {$toLower: '$geoLocationCountryCode'},
             count: { $sum: 1 },
             domain: { $addToSet: '$domain' }
-        }
-    },
-    { $sort : { count : -1} }
-]);
-
-       https://stackoverflow.com/questions/31643109/mongodb-aggregation-with-java-driver
-       https://stackoverflow.com/questions/48000891/parse-mongodb-json-query-in-java-with-multiple-criteria
-       Not Java: https://stackoverflow.com/questions/39060221/a-pipeline-stage-specification-object-must-contain-exactly-one-field-with-php-mo
-
-       (https://stackoverflow.com/questions/55029222/parse-mongodb-query-to-java)
-       https://www.programcreek.com/java-api-examples/?api=com.mongodb.client.model.Aggregates
-       On using group(TExpression) inside collection.aggregate().
+          }
+	 },
+	 { $sort : { count : -1} }
+	]);
+
     */
     public String aggregateContainsMRIForOverseas() {
@@ -415,5 +420,5 @@
 		 group("$geoLocationCountryCode", Arrays.asList(sum("count", 1), addToSet("domain", "$domain"))),
 		 sort(BasicDBObject.parse("{count : -1}"))
-						 ));
+	 ));
 	
 	for (Document doc : output) {
@@ -424,4 +429,70 @@
 	return "";
     }
+
+
+    /**       
+       The mongodb aggregate() we want to run this time:
+
+       db.Websites.aggregate([
+       {
+        $match: {
+            $and: [
+                {numPagesContainingMRI: {$gt: 0}},
+                {$or: [{geoLocationCountryCode:"NZ"},{domain: /\.nz/}]}
+            ]
+          }
+	},
+	{ $unwind: "$geoLocationCountryCode" },
+	{
+          $group: {
+            _id: "nz",
+            count: { $sum: 1 },
+            domain: { $addToSet: '$domain' }
+          }
+	},
+	{ $sort : { count : -1} }
+	]);
+    */
+    public String aggregateContainsMRIForNZ() {
+	// working with the WebSites collection, not WebPages collection!
+	MongoCollection<Document> collection = this.database.getCollection(WEBSITES_COLLECTION);
+
+	
+	//String isMRI_filter = 
+    
+	Bson orQuery = or(
+			  BasicDBObject.parse("{geoLocationCountryCode: \"NZ\"}"),
+			  BasicDBObject.parse("{domain: /\\.nz/}")
+			  );
+	Bson andQuery = and(
+		BasicDBObject.parse("{numPagesContainingMRI: {$gt: 0}}"),
+		orQuery);
+	
+	AggregateIterable<Document> output
+	    = collection.aggregate(Arrays.asList(
+		 match(andQuery),
+		 unwind("$geoLocationCountryCode"),
+		 group("NZ", Arrays.asList(sum("count", 1), addToSet("domain", "$domain"))),
+		 sort(BasicDBObject.parse("{count : -1}"))
+	 ));
+
+	// should only have one doc
+	for (Document doc : output) {
+	    //System.out.println(doc);
+	    System.out.println(doc.toJson());
+	}
+
+	return "";
+    }
+
+    public void writeToFile(boolean append, String filename, AggregateIterable<Document> output) {
+	
+	// should only have one doc
+	for (Document doc : output) {
+	    //System.out.println(doc);
+	    System.out.println(doc.toJson());
+	}
+    }
+    
     
     /** https://stackoverflow.com/questions/19938153/do-i-need-to-explicitly-close-connection */
Index: /other-projects/maori-lang-detection/src/org/greenstone/atea/WebPageURLsListing.java
===================================================================
--- /other-projects/maori-lang-detection/src/org/greenstone/atea/WebPageURLsListing.java	(revision 33878)
+++ /other-projects/maori-lang-detection/src/org/greenstone/atea/WebPageURLsListing.java	(revision 33879)
@@ -152,4 +152,5 @@
 	    //String isMRIFile = listing.produceURLsForPagesInMRI();
 	    //String containsMRIFile = listing.produceURLsForPagesContainingMRI();
+	    mongodb.aggregateContainsMRIForNZ();
 	    mongodb.aggregateContainsMRIForOverseas();
 	    
