Example usage for com.mongodb.client.model IndexOptions IndexOptions

List of usage examples for com.mongodb.client.model IndexOptions IndexOptions

Introduction

In this page you can find the example usage for com.mongodb.client.model IndexOptions IndexOptions.

Prototype

IndexOptions

Source Link

Usage

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   w w w  .j  a  v a 2 s. c o  m
            new Document(CHROMOSOME_FIELD, 1).append(START_FIELD, 1).append(END_FIELD, 1), background);
}