com.mongodb.client.MongoCursor Java Examples
The following examples show how to use
com.mongodb.client.MongoCursor.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: NamedQueryRegistration.java From epcis with Apache License 2.0 | 7 votes |
/** * Provide existing Named Event Queries */ @RequestMapping(value = "/Admin/NamedEventQuery", method = RequestMethod.GET) @ResponseBody public ResponseEntity<?> getNamedEventQueries() { HttpHeaders responseHeaders = new HttpHeaders(); responseHeaders.add("Content-Type", "application/json; charset=utf-8"); MongoCollection<BsonDocument> collection = Configuration.mongoDatabase.getCollection("NamedEventQuery", BsonDocument.class); MongoCursor<BsonDocument> cursor = collection.find().iterator(); JSONArray jarray = new JSONArray(); while (cursor.hasNext()) { BsonDocument doc = cursor.next(); JSONObject json = new JSONObject(doc.toJson()); jarray.put(json); } return new ResponseEntity<>(jarray.toString(1), responseHeaders, HttpStatus.OK); }
Example #2
Source File: MongoDao.java From Liudao with GNU General Public License v3.0 | 7 votes |
/** * 根据统计字段计算统计结果(gte最小值)并排序 * * @param collectionName 集合名 * @param match match条件 * @param field 统计字段 * @param minCount 最小值 * @return */ public LinkedHashMap<String, Integer> sortMap(String collectionName, Document match, String field, int minCount) { AggregateIterable<Document> aggregate = getDB().getCollection(collectionName).aggregate( Arrays.asList( match(match) , group("$" + field, Accumulators.sum("_count", 1)) , match(new Document("_count", new Document("$gte", minCount))) , sort(new Document("_count", -1)) ) ); LinkedHashMap<String, Integer> map = new LinkedHashMap<String, Integer>(); MongoCursor<Document> iterator = aggregate.iterator(); while (iterator.hasNext()) { Document next = iterator.next(); map.put(next.getString("_id"), next.getInteger("_count")); } return map; }
Example #3
Source File: MongodbHelper.java From cassandana with Apache License 2.0 | 6 votes |
@Override public AclEntity getAcl(String topic, String username, String clientId) { FindIterable<Document> findIterable = aclCollection.find(eq("username", username)); MongoCursor<Document> cursor = findIterable.iterator(); AclEntity acl = null; if(cursor.hasNext()) { Document document = cursor.next(); acl = new AclEntity(); acl.username = username; acl.clientId = clientId; acl.topic = topic; acl.canPublish = (document.getInteger("write") == 1); acl.canSubscribe = (document.getInteger("read") == 1); } cursor.close(); return acl; }
Example #4
Source File: MongoAdminClient.java From df_data_service with Apache License 2.0 | 6 votes |
public boolean collectionExists(String collectionName) { if (this.database == null) { return false; } final MongoIterable<String> iterable = database.listCollectionNames(); try (final MongoCursor<String> it = iterable.iterator()) { while (it.hasNext()) { if (it.next().equalsIgnoreCase(collectionName)) { return true; } } } return false; }
Example #5
Source File: ResourceDAO.java From SI with BSD 2-Clause "Simplified" License | 6 votes |
public List<Document> getDocuments(BasicDBObject query, RESOURCE_TYPE resType, String sortKey, boolean asc, int limit) { ArrayList<Document> docList = new ArrayList<Document>(); BasicDBObject sort = new BasicDBObject(sortKey, asc ? 1 : -1); MongoCollection<Document> collection = context.getDatabaseManager() .getCollection(collectionName); MongoCursor<Document> cursor = collection.find(query).sort(sort) .limit(limit).iterator(); while (cursor.hasNext()) { docList.add(cursor.next()); } return docList; }
Example #6
Source File: ChronoGraph.java From epcis with Apache License 2.0 | 6 votes |
/** * Return an iterable to all the edges in the graph. If this is not possible for * the implementation, then an UnsupportedOperationException can be thrown. * * @return * * @return an iterable reference to all edges in the graph */ public Stream<ChronoEdge> getChronoEdgeStream(boolean isParallel) { HashSet<ChronoEdge> ret = new HashSet<ChronoEdge>(); MongoCursor<BsonDocument> cursor = edges.find().projection(Tokens.PRJ_ONLY_OUTV_LABEL_INV).iterator(); while (cursor.hasNext()) { BsonDocument v = cursor.next(); String outV = v.getString(Tokens.OUT_VERTEX).getValue(); String label = v.getString(Tokens.LABEL).getValue(); String inV = v.getString(Tokens.IN_VERTEX).getValue(); String id = outV + "|" + label + "|" + inV; ret.add(new ChronoEdge(id, outV, inV, label, this)); } if (isParallel) return ret.parallelStream(); else return ret.stream(); }
Example #7
Source File: ReNounScoring.java From baleen with Apache License 2.0 | 6 votes |
private SetMultimap<ReNounFact, ScoredPattern> getFactToScoredPatternMultimap( MongoCollection<Document> factsCollection, MongoCollection<Document> scoredPatternsCollection) { SetMultimap<ReNounFact, ScoredPattern> factToPatternMap = HashMultimap.create(); MongoCursor<Document> scoredPatternsCursor = scoredPatternsCollection.find().iterator(); while (scoredPatternsCursor.hasNext()) { Document scoredPatternDocument = scoredPatternsCursor.next(); Iterator<Document> factsMatchingScoredPatternIterator = factsCollection .find(eq(PATTERN_FACT_FIELD, scoredPatternDocument.get(PATTERN_FACT_FIELD))) .iterator(); while (factsMatchingScoredPatternIterator.hasNext()) { Document factMatchingScoredPattern = factsMatchingScoredPatternIterator.next(); ReNounFact fact = new ReNounFact(factMatchingScoredPattern); ScoredPattern scoredPattern = new ScoredPattern(scoredPatternDocument); factToPatternMap.put(fact, scoredPattern); } } return factToPatternMap; }
Example #8
Source File: MatchDao.java From render with GNU General Public License v2.0 | 6 votes |
private List<String> getDistinctIdsForField(final MatchCollectionId collectionId, final String fieldName) { MongoUtil.validateRequiredParameter("collectionId", collectionId); final List<String> distinctIds = new ArrayList<>(8096); final MongoCollection<Document> collection = getExistingCollection(collectionId); try (final MongoCursor<String> cursor = collection.distinct(fieldName, String.class).iterator()) { while (cursor.hasNext()) { distinctIds.add(cursor.next()); } } return distinctIds; }
Example #9
Source File: IterateOperation.java From mongodb-performance-test with GNU Affero General Public License v3.0 | 6 votes |
@Override long executeQuery(int threadId, long threadRunCount, long globalRunCount, long selectorId, long randomId){ final MongoCursor<Document> cursor = mongoCollection.find(eq(queriedField, selectorId)).iterator(); //final MongoCursor<Document> cursor = mongoCollection.find(in(queriedField, selectorId, selectorId+1, selectorId+2, selectorId+3, selectorId+4)).iterator(); long result = 0; try { while (cursor.hasNext()) { final Document doc = cursor.next(); LOG.debug("Document {}", doc.toJson()); result++; } } finally { cursor.close(); } return result; }
Example #10
Source File: RenderDao.java From render with GNU General Public License v2.0 | 6 votes |
private List<TransformSpec> getTransformSpecs(final MongoCollection<Document> transformCollection, final Set<String> specIds) { final int specCount = specIds.size(); final List<TransformSpec> transformSpecList = new ArrayList<>(specCount); if (specCount > 0) { final Document transformQuery = new Document(); transformQuery.put("id", new Document(QueryOperators.IN, specIds)); LOG.debug("getTransformSpecs: {}.find({})", MongoUtil.fullName(transformCollection), transformQuery.toJson()); try (final MongoCursor<Document> cursor = transformCollection.find(transformQuery).iterator()) { Document document; TransformSpec transformSpec; while (cursor.hasNext()) { document = cursor.next(); transformSpec = TransformSpec.fromJson(document.toJson()); transformSpecList.add(transformSpec); } } } return transformSpecList; }
Example #11
Source File: MongoSdkBase.java From Mongodb-WeAdmin with Apache License 2.0 | 6 votes |
/** * 查询所有记录 代码控制返回结果数 * * @param table 表连接 * @param filter 条件 com.mongodb.client.model.Filter * @param sort 排序 com.mongodb.client.model.Sorts 可空 * @return */ public List<JSONObject> getAll(MongoCollection table, Bson filter, Bson sort) { List<JSONObject> list = new ArrayList<JSONObject>(); FindIterable<Document> result = null; if (filter == null) { result = table.find().sort(sort); } else { result = table.find(filter).sort(sort); } MongoCursor<Document> iterator = result.iterator(); while (iterator.hasNext()) { Object ddd = iterator.next(); list.add(JSON.parseObject(diyObjectIdToJson(ddd))); } return list; }
Example #12
Source File: MongoDBFactory.java From database-transform-tool with Apache License 2.0 | 6 votes |
/** * @decription 查询数据库表名 * @author yi.zhang * @time 2017年6月30日 下午2:16:02 * @param table 表名 * @return */ public List<String> queryTables(){ try { if(session==null){ init(servers, database, schema, username, password); } MongoIterable<String> collection = session.listCollectionNames(); if (collection == null) { return null; } List<String> tables = new ArrayList<String>(); MongoCursor<String> cursor = collection.iterator(); while(cursor.hasNext()){ String table = cursor.next(); tables.add(table); } return tables; } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; }
Example #13
Source File: MongoDBConnection.java From nationalparks with Apache License 2.0 | 6 votes |
/** * @return */ public List<Park> getAll() { System.out.println("[DEBUG] MongoDBConnection.getAll()"); ArrayList<Park> allParksList = new ArrayList<Park>(); if (mongoDB != null) { try { MongoCollection parks = mongoDB.getCollection(COLLECTION); MongoCursor<Document> cursor = parks.find().iterator(); try { while (cursor.hasNext()) { allParksList.add(ParkReadConverter.convert(cursor.next())); } } finally { cursor.close(); } } catch (Exception e) { System.out.println("[ERROR] Error connecting to MongoDB. " + e.getMessage()); } } else { System.out.println("[ERROR] mongoDB could not be initiallized. No operation with DB will be performed"); } return allParksList; }
Example #14
Source File: ChronoGraph.java From epcis with Apache License 2.0 | 6 votes |
/** * Geospatial query * * @param key should be indexed by 2dsphere * db.vertices.createIndex({"urn:oliot:ubv:mda:gps" : "2dsphere"}) * @param lon * @param lat * @param radius in metres db.vertices.find({ "urn:oliot:ubv:mda:gps" : { $near * : { $geometry: { type: "Point", coordinates: [ -1.1673,52.93]}, * $maxDistance: 50000}}}) * * @return */ public HashSet<ChronoVertex> getChronoVertexSet(String key, double lon, double lat, double radius) { HashSet<ChronoVertex> ret = new HashSet<ChronoVertex>(); BsonArray coordinates = new BsonArray(); coordinates.add(new BsonDouble(lon)); coordinates.add(new BsonDouble(lat)); BsonDocument geometry = new BsonDocument(); geometry.put("type", new BsonString("Point")); geometry.put("coordinates", coordinates); BsonDocument near = new BsonDocument(); near.put("$geometry", geometry); near.put("$maxDistance", new BsonDouble(radius)); BsonDocument geoquery = new BsonDocument(); geoquery.put("$near", near); BsonDocument queryDoc = new BsonDocument(); queryDoc.put(key, geoquery); MongoCursor<BsonDocument> cursor = vertices.find(queryDoc).projection(Tokens.PRJ_ONLY_ID).iterator(); while (cursor.hasNext()) { BsonDocument v = cursor.next(); ret.add(new ChronoVertex(v.getString(Tokens.ID).getValue(), this)); } return ret; }
Example #15
Source File: MongoStorage.java From LuckPerms with MIT License | 6 votes |
@Override public void loadAllTracks() { List<String> tracks = new ArrayList<>(); MongoCollection<Document> c = this.database.getCollection(this.prefix + "tracks"); try (MongoCursor<Document> cursor = c.find().iterator()) { while (cursor.hasNext()) { String name = cursor.next().getString("_id"); tracks.add(name); } } if (!Iterators.tryIterate(tracks, this::loadTrack)) { throw new RuntimeException("Exception occurred whilst loading a track"); } this.plugin.getTrackManager().retainAll(tracks); }
Example #16
Source File: MongoWrapperDefaultHandler.java From DBus with Apache License 2.0 | 6 votes |
/** * 根据oid去数据库回查数据 * * @param oid * @return */ private Document fetchData(String schemaName, String tableName, String oid) { Document result = null; DbusDatasource datasource = GlobalCache.getDatasource(); MongoClientURI uri = new MongoClientURI(datasource.getMasterUrl()); MongoClient client = new MongoClient(uri); MongoDatabase database = client.getDatabase(schemaName); MongoCollection<Document> collection = database.getCollection(tableName); MongoCursor<Document> cursor = collection.find(new BasicDBObject().append("_id", new ObjectId(oid))).iterator(); if (cursor.hasNext()) { result = cursor.next(); } else { logger.error("get source data error. schemaName:{}, tableName:{}, oid:{}", schemaName, tableName, oid); } client.close(); return result; }
Example #17
Source File: MongoStorage.java From LuckPerms with MIT License | 6 votes |
@Override public <N extends Node> List<NodeEntry<String, N>> searchGroupNodes(ConstraintNodeMatcher<N> constraint) throws Exception { List<NodeEntry<String, N>> held = new ArrayList<>(); MongoCollection<Document> c = this.database.getCollection(this.prefix + "groups"); try (MongoCursor<Document> cursor = c.find().iterator()) { while (cursor.hasNext()) { Document d = cursor.next(); String holder = d.getString("_id"); Set<Node> nodes = new HashSet<>(nodesFromDoc(d)); for (Node e : nodes) { N match = constraint.match(e); if (match != null) { held.add(NodeEntry.of(holder, match)); } } } } return held; }
Example #18
Source File: TestMongoClient.java From jframe with Apache License 2.0 | 6 votes |
public void testDatabase() { ListDatabasesIterable<Document> list = mongoClient.listDatabases(); MongoCursor<Document> iterD = list.iterator(); while (iterD.hasNext()) { Document doc = iterD.next(); System.out.println(doc); if (!doc.getBoolean("empty", true)) { System.out.println(mongoClient.getDatabase(doc .getString("name"))); } } // MongoIterable<String> mongo = mongoClient.listDatabaseNames(); // MongoCursor<String> iter = mongo.iterator(); // while (iter.hasNext()) { // System.out.println(iter.next()); // } }
Example #19
Source File: MongoStorage.java From LuckPerms with MIT License | 6 votes |
@Override public <N extends Node> List<NodeEntry<UUID, N>> searchUserNodes(ConstraintNodeMatcher<N> constraint) throws Exception { List<NodeEntry<UUID, N>> held = new ArrayList<>(); MongoCollection<Document> c = this.database.getCollection(this.prefix + "users"); try (MongoCursor<Document> cursor = c.find().iterator()) { while (cursor.hasNext()) { Document d = cursor.next(); UUID holder = getDocumentId(d); Set<Node> nodes = new HashSet<>(nodesFromDoc(d)); for (Node e : nodes) { N match = constraint.match(e); if (match != null) { held.add(NodeEntry.of(holder, match)); } } } } return held; }
Example #20
Source File: MongoDBConnection.java From nationalparks with Apache License 2.0 | 6 votes |
/** * @param query * @return */ public List<Park> getByQuery(BasicDBObject query) { System.out.println("[DEBUG] MongoDBConnection.getByQuery()"); List<Park> parks = new ArrayList<Park>(); if (mongoDB != null) { try { MongoCursor<Document> cursor = mongoDB.getCollection(COLLECTION).find(query).iterator(); int i = 0; try { while (cursor.hasNext()) { parks.add(ParkReadConverter.convert(cursor.next())); } } finally { cursor.close(); } } catch (Exception e) { System.out.println("[ERROR] Error connecting to MongoDB. " + e.getMessage()); } } else { System.out.println("[ERROR] mongoDB could not be initiallized. No operation with DB will be performed"); } return parks; }
Example #21
Source File: GameUniverse.java From Much-Assembly-Required with GNU General Public License v3.0 | 6 votes |
/** * Attempts loading a world from mongoDB by coordinates * * @param x the x coordinate of the world * @param y the y coordinate of the world * * @return World, null if not found */ private World loadWorld(int x, int y, String dimension) { MongoDatabase db = mongo.getDatabase(GameServer.INSTANCE.getConfig().getString("mongo_dbname")); MongoCollection<Document> worlds = db.getCollection("world"); Document whereQuery = new Document(); whereQuery.put("_id", World.idFromCoordinates(x, y, dimension)); MongoCursor<Document> cursor = worlds.find(whereQuery).iterator(); if (cursor.hasNext()) { return World.deserialize(cursor.next()); } else{ return null; } }
Example #22
Source File: RestaurantService.java From HTTP-RPC with Apache License 2.0 | 5 votes |
@RequestMethod("GET") public void getRestaurants(String zipCode, String format) throws IOException { MongoDatabase db = mongoClient.getDatabase("test"); FindIterable<Document> iterable = db.getCollection("restaurants").find(new Document("address.zipcode", zipCode)); try (MongoCursor<Document> cursor = iterable.iterator()) { Iterable<Document> cursorAdapter = () -> cursor; if (format == null || format.equals("json")) { getResponse().setContentType("application/json"); JSONEncoder jsonEncoder = new JSONEncoder(); jsonEncoder.write(cursorAdapter, getResponse().getOutputStream()); } else if (format.equals("csv")) { getResponse().setContentType("text/csv"); CSVEncoder csvEncoder = new CSVEncoder(Arrays.asList("name", "address.building", "address.street", "borough", "cuisine")); csvEncoder.write(cursorAdapter, getResponse().getOutputStream()); } else if (format.equals("html")) { getResponse().setContentType("text/html"); TemplateEncoder templateEncoder = new TemplateEncoder(getClass().getResource("restaurants.html")); templateEncoder.setBaseName(getClass().getPackage().getName() + ".restaurants"); templateEncoder.write(cursorAdapter, getResponse().getOutputStream()); } else { throw new IllegalArgumentException(); } } }
Example #23
Source File: ReNounPatternGenerationTest.java From baleen with Apache License 2.0 | 5 votes |
@Test public void testSeedPatterns() throws AnalysisEngineProcessException, ResourceInitializationException { jCas.setDocumentText( SENTENCE_1 + SENTENCE_2 + SENTENCE_3 + SENTENCE_4 + SENTENCE_5 + SENTENCE_6 + SENTENCE_7 + SENTENCE_8); processJCas(); MongoCursor<Document> found = output.find().iterator(); assertTrue(found.hasNext()); int count = 0; while (found.hasNext()) { count++; Document next = found.next(); assertEquals("Google", next.get(SUBJECT_FIELD)); assertEquals("CEO", next.get(ATTRIBUTE_FIELD)); assertEquals("Larry Page", next.get(OBJECT_FIELD)); assertNotNull(next.get(SENTENCE_FIELD)); assertNotNull(next.get(PATTERN_FIELD)); } assertEquals(8, count); }
Example #24
Source File: MongoStorage.java From LuckPerms with MIT License | 5 votes |
@Override public Set<UUID> getUniqueUsers() { Set<UUID> uuids = new HashSet<>(); MongoCollection<Document> c = this.database.getCollection(this.prefix + "users"); try (MongoCursor<Document> cursor = c.find().iterator()) { while (cursor.hasNext()) { try { uuids.add(getDocumentId(cursor.next())); } catch (IllegalArgumentException e) { // ignore } } } return uuids; }
Example #25
Source File: MaxEntClassifierTrainerTest.java From baleen with Apache License 2.0 | 5 votes |
@Test public void testTaskSavesValuesToMongo() throws Exception { FindIterable<Document> find = documents.find(); MongoCursor<Document> iterator = find.iterator(); int count = 0; ImmutableList<String> labels = ImmutableList.of("pos", "neg"); while (iterator.hasNext()) { Document document = iterator.next(); String classification = document.getString(CLASSIFICATION_FIELD); assertTrue(labels.contains(classification)); count++; } assertEquals(16, count); }
Example #26
Source File: DeleteGridFS.java From nifi with Apache License 2.0 | 5 votes |
@Override public void onTrigger(ProcessContext context, ProcessSession session) throws ProcessException { FlowFile input = session.get(); if (input == null) { return; } final String deleteQuery = getQuery(context, input); final String queryAttribute = context.getProperty(QUERY_ATTRIBUTE).isSet() ? context.getProperty(QUERY_ATTRIBUTE).evaluateAttributeExpressions(input).getValue() : null; GridFSBucket bucket = getBucket(input, context); try { Document query = Document.parse(deleteQuery); MongoCursor cursor = bucket.find(query).iterator(); if (cursor.hasNext()) { GridFSFile file = (GridFSFile)cursor.next(); bucket.delete(file.getObjectId()); if (!StringUtils.isEmpty(queryAttribute)) { input = session.putAttribute(input, queryAttribute, deleteQuery); } session.transfer(input, REL_SUCCESS); } else { getLogger().error(String.format("Query %s did not delete anything in %s", deleteQuery, bucket.getBucketName())); session.transfer(input, REL_FAILURE); } cursor.close(); } catch (Exception ex) { getLogger().error(String.format("Error deleting using query: %s", deleteQuery), ex); session.transfer(input, REL_FAILURE); } }
Example #27
Source File: GenericDAO.java From repositoryminer with Apache License 2.0 | 5 votes |
/** * Converts a query cursor to a list. * * @param cursor * the query cursor. * @return a list of documents. */ public List<Document> fromCursorToList(MongoCursor<Document> cursor) { List<Document> list = new ArrayList<Document>(); while (cursor.hasNext()) { list.add(cursor.next()); } cursor.close(); return list; }
Example #28
Source File: MongoStorage.java From LuckPerms with MIT License | 5 votes |
@Override public Optional<Track> loadTrack(String name) { Track track = this.plugin.getTrackManager().getIfLoaded(name); if (track != null) { track.getIoLock().lock(); } try { MongoCollection<Document> c = this.database.getCollection(this.prefix + "tracks"); try (MongoCursor<Document> cursor = c.find(new Document("_id", name)).iterator()) { if (!cursor.hasNext()) { return Optional.empty(); } if (track == null) { track = this.plugin.getTrackManager().getOrMake(name); track.getIoLock().lock(); } Document d = cursor.next(); //noinspection unchecked track.setGroups((List<String>) d.get("groups")); } } finally { if (track != null) { track.getIoLock().unlock(); } } return Optional.of(track); }
Example #29
Source File: ChronoGraph.java From epcis with Apache License 2.0 | 5 votes |
/** * Return an iterable to all the vertices in the graph. If this is not possible * for the implementation, then an UnsupportedOperationException can be thrown. * * @return an iterable reference to all vertices in the graph */ public Set<ChronoVertex> getChronoVertexSet() { HashSet<String> idSet = new HashSet<String>(); Function<BsonDocument, String> mapper = new Function<BsonDocument, String>() { @Override public String apply(BsonDocument val) { return val.getString(Tokens.ID).getValue(); } }; HashSet<String> outV = new HashSet<String>(); ArrayList<BsonDocument> outVQuery = new ArrayList<BsonDocument>(); outVQuery.add(new BsonDocument("$group", new BsonDocument(Tokens.ID, new BsonString("$" + Tokens.OUT_VERTEX)))); edges.aggregate(outVQuery).map(mapper).into(outV); HashSet<String> inV = new HashSet<String>(); ArrayList<BsonDocument> inVQuery = new ArrayList<BsonDocument>(); inVQuery.add(new BsonDocument("$group", new BsonDocument(Tokens.ID, new BsonString("$" + Tokens.IN_VERTEX)))); edges.aggregate(inVQuery).map(mapper).into(inV); idSet.addAll(inV); MongoCursor<BsonDocument> vi = vertices.find(Tokens.FLT_VERTEX_FIELD_NOT_INCLUDED) .projection(Tokens.PRJ_ONLY_ID).iterator(); while (vi.hasNext()) { BsonDocument d = vi.next(); idSet.add(d.getString(Tokens.ID).getValue()); } return idSet.parallelStream().map(s -> new ChronoVertex(s, this)).collect(Collectors.toSet()); }
Example #30
Source File: ResourceDAO.java From SI with BSD 2-Clause "Simplified" License | 5 votes |
public List<Document> getDocuments(String keyName, String keyValue) { ArrayList<Document> docList = new ArrayList<Document>(); MongoCollection<Document> collection = context.getDatabaseManager() .getCollection(collectionName); MongoCursor<Document> cursor = collection.find( new BasicDBObject(keyName, keyValue)).iterator(); while (cursor.hasNext()) { docList.add(cursor.next()); } return docList; }