Ensure that indices are created in mongo
It's not clear if we are creating indices consistently in all branches and in all the collections that need them.

For example, in 0.5 currently there are no indices in `variants` collection.

diff --git a/opencga-storage/opencga-storage-mongodb/src/main/java/org/opencb/opencga/storage/mongodb/variant/VariantMongoDBWriter.java b/opencga-storage/opencga-storage-mongodb/src/main/java/org/opencb/opencga/storage/mongodb/variant/VariantMongoDBWriter.java
index 5504f07c64..8604fd22fc 100644
--- a/opencga-storage/opencga-storage-mongodb/src/main/java/org/opencb/opencga/storage/mongodb/variant/VariantMongoDBWriter.java
+++ b/opencga-storage/opencga-storage-mongodb/src/main/java/org/opencb/opencga/storage/mongodb/variant/VariantMongoDBWriter.java
@@ -461,21 +461,21 @@ public class VariantMongoDBWriter extends VariantDBWriter {
         logger.info("POST");
         writeSourceSummary(source);
 
-        DBObject empty = new BasicDBObject();   // are we sure a null won't raise nullptrException? it doesn't seem to be checks anywhere
-        variantMongoCollection.createIndex(new BasicDBObject("_at.chunkIds", 1), empty);
-        variantMongoCollection.createIndex(new BasicDBObject("annot.xrefs.id", 1), empty);
-        variantMongoCollection.createIndex(new BasicDBObject("annot.ct.so", 1), empty);
-        variantMongoCollection.createIndex(new BasicDBObject(DBObjectToVariantConverter.IDS_FIELD, 1), empty);
-        variantMongoCollection.createIndex(new BasicDBObject(DBObjectToVariantConverter.CHROMOSOME_FIELD, 1), empty);
+        DBObject onBackground = new BasicDBObject("background", true);
+        variantMongoCollection.createIndex(new BasicDBObject("_at.chunkIds", 1), onBackground);
+        variantMongoCollection.createIndex(new BasicDBObject("annot.xrefs.id", 1), onBackground);
+        variantMongoCollection.createIndex(new BasicDBObject("annot.ct.so", 1), onBackground);
+        variantMongoCollection.createIndex(new BasicDBObject(DBObjectToVariantConverter.IDS_FIELD, 1), onBackground);
+        variantMongoCollection.createIndex(new BasicDBObject(DBObjectToVariantConverter.CHROMOSOME_FIELD, 1), onBackground);
         variantMongoCollection.createIndex(
                 new BasicDBObject(DBObjectToVariantConverter.FILES_FIELD + "." + DBObjectToVariantSourceEntryConverter.STUDYID_FIELD, 1)
-                        .append(DBObjectToVariantConverter.FILES_FIELD + "." + DBObjectToVariantSourceEntryConverter.FILEID_FIELD, 1), empty);
-        variantMongoCollection.createIndex(new BasicDBObject("st.maf", 1), empty);
-        variantMongoCollection.createIndex(new BasicDBObject("st.mgf", 1), empty);
+                        .append(DBObjectToVariantConverter.FILES_FIELD + "." + DBObjectToVariantSourceEntryConverter.FILEID_FIELD, 1), onBackground);
+        variantMongoCollection.createIndex(new BasicDBObject("st.maf", 1), onBackground);
+        variantMongoCollection.createIndex(new BasicDBObject("st.mgf", 1), onBackground);
         variantMongoCollection.createIndex(
                 new BasicDBObject(DBObjectToVariantConverter.CHROMOSOME_FIELD, 1)
                         .append(DBObjectToVariantConverter.START_FIELD, 1)
-                        .append(DBObjectToVariantConverter.END_FIELD, 1), empty);
+                        .append(DBObjectToVariantConverter.END_FIELD, 1), onBackground);
         logger.debug("sent order to create indices");
 
         logger.debug("checkExistsTime " + checkExistsTime / 1000000.0 + "ms ");
['opencga-storage/opencga-storage-mongodb/src/main/java/org/opencb/opencga/storage/mongodb/variant/VariantMongoDBWriter.java']