@SuppressWarnings("deprecation") com.mongodb.client.model.IndexOptions convert(final IndexOptions options, final boolean background) { if (options.dropDups()) { LOG.warn("Support for dropDups has been removed from the server. Please remove this setting."); } com.mongodb.client.model.IndexOptions indexOptions = new com.mongodb.client.model.IndexOptions() .background(options.background() || background) .sparse(options.sparse()) .unique(options.unique()); if (!options.language().equals("")) { indexOptions.defaultLanguage(options.language()); } if (!options.languageOverride().equals("")) { indexOptions.languageOverride(options.languageOverride()); } if (!options.name().equals("")) { indexOptions.name(options.name()); } if (options.expireAfterSeconds() != -1) { indexOptions.expireAfter((long) options.expireAfterSeconds(), TimeUnit.SECONDS); } if (!options.partialFilter().equals("")) { indexOptions.partialFilterExpression(Document.parse(options.partialFilter())); } if (!options.collation().locale().equals("")) { indexOptions.collation(convert(options.collation())); } return indexOptions; }
ops = ops.background((Boolean) indexOptions.get("background"));
@Override public IndexOptions convert(Environment env, TraceInfo trace, Memory arg) throws Throwable { if (arg.isNull()) return null; ArrayMemory arr = arg.toValue(ArrayMemory.class); IndexOptions options = new IndexOptions(); if (arr.containsKey("background")) { options.background(arg.valueOfIndex("background").toBoolean()); } if (arr.containsKey("defaultLanguage")) { options.defaultLanguage(arg.valueOfIndex("defaultLanguage").toString()); } if (arr.containsKey("bits")) { options.bits(arg.valueOfIndex("bits").toInteger()); } if (arr.containsKey("name")) { options.name(arg.valueOfIndex("name").toString()); } if (arr.containsKey("max")) { options.max(arg.valueOfIndex("max").toDouble()); } if (arr.containsKey("min")) { options.min(arg.valueOfIndex("min").toDouble()); } if (arr.containsKey("languageOverride")) { options.languageOverride(arg.valueOfIndex("languageOverride").toString()); } if (arr.containsKey("sparse")) { options.sparse(arg.valueOfIndex("sparse").toBoolean()); } if (arr.containsKey("unique")) { options.unique(arg.valueOfIndex("unique").toBoolean()); } if (arr.containsKey("version")) { options.version(arg.valueOfIndex("version").toInteger()); } if (arr.containsKey("textVersion")) { options.textVersion(arg.valueOfIndex("textVersion").toInteger()); } if (arr.containsKey("sphereVersion")) { options.sphereVersion(arg.valueOfIndex("sphereVersion").toInteger()); } return options; }
ops = ops.background((Boolean) indexOptions.get("background"));
options.background(true); BasicDBObject weights = new BasicDBObject(); weights.put("lorem", 15);
break; case "background": indexOptions.background(Boolean.parseBoolean(value.toString())); break; case "name":
/** * Creates a new {@link IndexModel}, which can be used for creating indices using MongoDB Java drivers. * * @return the created {@link IndexModel} */ public IndexModel toIndexModel() { final IndexOptions options = new IndexOptions() .name(name) .unique(unique) .sparse(sparse) .background(background); if (!partialFilterExpression.isEmpty()) { options.partialFilterExpression(partialFilterExpression); } return new IndexModel(keys, options); }
/** * Creates a new {@link IndexModel}, which can be used for creating indices using MongoDB Java drivers. * * @return the created {@link IndexModel} */ public IndexModel toIndexModel() { final IndexOptions options = new IndexOptions() .name(name) .unique(unique) .sparse(sparse) .background(background); if (!partialFilterExpression.isEmpty()) { options.partialFilterExpression(partialFilterExpression); } return new IndexModel(keys, options); }
private void init() { db = client.getDatabase(this.dbname); IndexOptions io = new IndexOptions().background(true).name("nameIndex"); BsonDocument doc = new BsonDocument(); doc.append("name", new BsonInt32(1)); IndexOptions io1 = new IndexOptions().background(true).unique(true).name("alertIndex"); BsonDocument doc1 = new BsonDocument(); doc1.append("alertId", new BsonInt32(1)); IndexOptions io1 = new IndexOptions().background(true).name("versionIndex"); doc1.append("version", new BsonInt32(1)); scheduleStates = getCollection("schedule_specs"); IndexOptions ioInternal = new IndexOptions().background(true).name("topologyIdIndex"); BsonDocument docInternal = new BsonDocument(); docInternal.append("topologyId", new BsonInt32(1)); IndexOptions ioInternal = new IndexOptions().background(true).name("topologyNameIndex"); BsonDocument docInternal = new BsonDocument(); docInternal.append("topologyName", new BsonInt32(1));
public QueryResult createIndex(Bson keys, ObjectMap options) { long start = startQuery(); IndexOptions i = new IndexOptions(); if (options.containsKey(UNIQUE)) { i.unique(options.getBoolean(UNIQUE)); } if (options.containsKey(BACKGROUND)) { i.background(options.getBoolean(BACKGROUND)); } if (options.containsKey(SPARSE)) { i.sparse(options.getBoolean(SPARSE)); } if (options.containsKey(NAME)) { i.name(options.getString(NAME)); } mongoDBNativeQuery.createIndex(keys, i); QueryResult queryResult = endQuery(Collections.emptyList(), start); return queryResult; }
@SuppressWarnings("deprecation") com.mongodb.client.model.IndexOptions convert(final IndexOptions options, final boolean background) { if (options.dropDups()) { LOG.warning("Support for dropDups has been removed from the server. Please remove this setting."); } com.mongodb.client.model.IndexOptions indexOptions = new com.mongodb.client.model.IndexOptions() .background(options.background() || background) .sparse(options.sparse()) .unique(options.unique()); if (!options.language().equals("")) { indexOptions.defaultLanguage(options.language()); } if (!options.languageOverride().equals("")) { indexOptions.languageOverride(options.languageOverride()); } if (!options.name().equals("")) { indexOptions.name(options.name()); } if (options.expireAfterSeconds() != -1) { indexOptions.expireAfter((long) options.expireAfterSeconds(), TimeUnit.SECONDS); } if (!options.partialFilter().equals("")) { indexOptions.partialFilterExpression(Document.parse(options.partialFilter())); } if (!options.collation().locale().equals("")) { indexOptions.collation(convert(options.collation())); } return indexOptions; }
@Override protected final void ensureIndexes() { IndexOptions options = new IndexOptions().background(true); collection().createIndex(Indexes.compoundIndex(Indexes.ascending(JobStructure.JOB_TYPE.key()), Indexes.descending(JobStructure.STARTED.key())), options); collection().createIndex(Indexes.ascending(JobStructure.STARTED.key()), options); collection().createIndex(Indexes.ascending(JobStructure.LAST_UPDATED.key(), JobStructure.STOPPED.key()), options); }
@Override protected final void ensureIndexes() { IndexOptions options = new IndexOptions().background(true); collection().createIndex(Indexes.compoundIndex(Indexes.ascending(JobStructure.JOB_TYPE.key()), Indexes.descending(JobStructure.STARTED.key())), options); collection().createIndex(Indexes.ascending(JobStructure.STARTED.key()), options); collection().createIndex(Indexes.ascending(JobStructure.LAST_UPDATED.key(), JobStructure.STOPPED.key()), options); }
indexOptions.name( indexName ).unique( unique ).background( options.getBoolean( "background" , false ) );
indexOptions.name( indexName ).unique( unique ).background( options.getBoolean( "background" , false ) );
mongoDbIndexOptions.background(indexOptions.getBoolean("background"));
public static IndexOptions toIndexOptions(final Document options) { final IndexOptions indexOptions = new IndexOptions(); applyIfTrue(options.containsKey("background"), () -> indexOptions.background(options.getBoolean("background"))); applyIfTrue(options.containsKey("bits"), () -> indexOptions.bits(options.getInteger("bits"))); applyIfTrue(options.containsKey("bucketSize"), () -> indexOptions.bucketSize(options.getDouble("bucketSize")));
ret.background(options.get("background").asBoolean().getValue());