List of usage examples for com.mongodb.client MongoCollection createIndex
String createIndex(ClientSession clientSession, Bson keys);
From source file:uk.ac.ebi.eva.dbmigration.mongodb.ExtractAnnotationFromVariant.java
License:Apache License
@ChangeSet(order = "005", id = "createIndexes", author = "EVA") public void createIndexes(MongoDatabase mongoDatabase) { final MongoCollection<Document> variantsCollection = mongoDatabase .getCollection(databaseParameters.getDbCollectionsVariantsName()); final MongoCollection<Document> annotationsCollection = mongoDatabase .getCollection(databaseParameters.getDbCollectionsAnnotationsName()); logger.info("5) create indexes collections {} and {}", annotationsCollection.getNamespace(), variantsCollection.getNamespace()); IndexOptions background = new IndexOptions().background(true); variantsCollection.createIndex(new Document(ANNOT_FIELD + "." + XREFS_FIELD, 1), background); variantsCollection.createIndex(new Document(ANNOT_FIELD + "." + SO_FIELD, 1), background); annotationsCollection.createIndex(new Document(CONSEQUENCE_TYPE_FIELD + "." + SO_FIELD, 1), background); annotationsCollection.createIndex(new Document(XREFS_FIELD + "." + XREF_ID_FIELD, 1), background); annotationsCollection.createIndex(/*from www .ja v a 2 s . com*/ new Document(CHROMOSOME_FIELD, 1).append(START_FIELD, 1).append(END_FIELD, 1), background); }