Codota Logo
IndexOptions.partialFilterExpression
Code IndexAdd Codota to your IDE (free)

How to use
partialFilterExpression
method
in
com.mongodb.client.model.IndexOptions

Best Java code snippets using com.mongodb.client.model.IndexOptions.partialFilterExpression (Showing top 19 results out of 315)

  • Common ways to obtain IndexOptions
private void myMethod () {
IndexOptions i =
  • Codota Iconnew IndexOptions()
  • Codota Iconnew IndexOptions().unique(true)
  • Smart code suggestions by Codota
}
origin: spring-projects/spring-data-mongodb

public Mono<String> ensureIndex(final IndexDefinition indexDefinition) {
  return mongoOperations.execute(collectionName, collection -> {
    Document indexOptions = indexDefinition.getIndexOptions();
    IndexOptions ops = IndexConverters.indexDefinitionToIndexOptionsConverter().convert(indexDefinition);
    if (indexOptions.containsKey(PARTIAL_FILTER_EXPRESSION_KEY)) {
      Assert.isInstanceOf(Document.class, indexOptions.get(PARTIAL_FILTER_EXPRESSION_KEY));
      MongoPersistentEntity<?> entity = type
          .map(val -> (MongoPersistentEntity) queryMapper.getMappingContext().getRequiredPersistentEntity(val))
          .orElseGet(() -> lookupPersistentEntity(collectionName));
      ops = ops.partialFilterExpression(
          queryMapper.getMappedObject(indexOptions.get(PARTIAL_FILTER_EXPRESSION_KEY, Document.class), entity));
    }
    return collection.createIndex(indexDefinition.getIndexKeys(), ops);
  }).next();
}
origin: spring-projects/spring-data-mongodb

public String ensureIndex(final IndexDefinition indexDefinition) {
  return execute(collection -> {
    Document indexOptions = indexDefinition.getIndexOptions();
    IndexOptions ops = IndexConverters.indexDefinitionToIndexOptionsConverter().convert(indexDefinition);
    if (indexOptions.containsKey(PARTIAL_FILTER_EXPRESSION_KEY)) {
      Assert.isInstanceOf(Document.class, indexOptions.get(PARTIAL_FILTER_EXPRESSION_KEY));
      ops.partialFilterExpression(mapper.getMappedObject((Document) indexOptions.get(PARTIAL_FILTER_EXPRESSION_KEY),
          lookupPersistentEntity(type, collectionName)));
    }
    return collection.createIndex(indexDefinition.getIndexKeys(), ops);
  });
}
origin: MorphiaOrg/morphia

@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;
}
origin: spring-projects/spring-data-mongodb

ops = ops.partialFilterExpression((org.bson.Document) indexOptions.get("partialFilterExpression"));
origin: org.springframework.data/spring-data-mongodb

public Mono<String> ensureIndex(final IndexDefinition indexDefinition) {
  return mongoOperations.execute(collectionName, collection -> {
    Document indexOptions = indexDefinition.getIndexOptions();
    IndexOptions ops = IndexConverters.indexDefinitionToIndexOptionsConverter().convert(indexDefinition);
    if (indexOptions.containsKey(PARTIAL_FILTER_EXPRESSION_KEY)) {
      Assert.isInstanceOf(Document.class, indexOptions.get(PARTIAL_FILTER_EXPRESSION_KEY));
      MongoPersistentEntity<?> entity = type
          .map(val -> (MongoPersistentEntity) queryMapper.getMappingContext().getRequiredPersistentEntity(val))
          .orElseGet(() -> lookupPersistentEntity(collectionName));
      ops = ops.partialFilterExpression(
          queryMapper.getMappedObject(indexOptions.get(PARTIAL_FILTER_EXPRESSION_KEY, Document.class), entity));
    }
    return collection.createIndex(indexDefinition.getIndexKeys(), ops);
  }).next();
}
origin: org.springframework.data/spring-data-mongodb

public String ensureIndex(final IndexDefinition indexDefinition) {
  return execute(collection -> {
    Document indexOptions = indexDefinition.getIndexOptions();
    IndexOptions ops = IndexConverters.indexDefinitionToIndexOptionsConverter().convert(indexDefinition);
    if (indexOptions.containsKey(PARTIAL_FILTER_EXPRESSION_KEY)) {
      Assert.isInstanceOf(Document.class, indexOptions.get(PARTIAL_FILTER_EXPRESSION_KEY));
      ops.partialFilterExpression(mapper.getMappedObject((Document) indexOptions.get(PARTIAL_FILTER_EXPRESSION_KEY),
          lookupPersistentEntity(type, collectionName)));
    }
    return collection.createIndex(indexDefinition.getIndexKeys(), ops);
  });
}
origin: org.springframework.data/spring-data-mongodb

ops = ops.partialFilterExpression((org.bson.Document) indexOptions.get("partialFilterExpression"));
origin: apache/jackrabbit-oak

/**
 * Forces creation of a partial index on a set of fields, if one does not
 * already exist.
 *
 * @param collection the collection.
 * @param fields the name of the fields.
 * @param ascending {@code true} for an ascending, {@code false} for a
 *                              descending index.
 * @param filter the filter expression for the partial index.
 * @throws MongoException if the operation fails.
 */
static void createPartialIndex(MongoCollection<?> collection,
                String[] fields,
                boolean[] ascending,
                String filter) throws MongoException {
  checkArgument(fields.length == ascending.length);
  BasicDBObject index = new BasicDBObject();
  for (int i = 0; i < fields.length; i++) {
    index.put(fields[i], ascending[i] ? 1 : -1);
  }
  IndexOptions options = new IndexOptions().partialFilterExpression(BasicDBObject.parse(filter));
  collection.createIndex(index, options);
}
origin: org.apache.jackrabbit/oak-store-document

/**
 * Forces creation of a partial index on a set of fields, if one does not
 * already exist.
 *
 * @param collection the collection.
 * @param fields the name of the fields.
 * @param ascending {@code true} for an ascending, {@code false} for a
 *                              descending index.
 * @param filter the filter expression for the partial index.
 * @throws MongoException if the operation fails.
 */
static void createPartialIndex(MongoCollection<?> collection,
                String[] fields,
                boolean[] ascending,
                String filter) throws MongoException {
  checkArgument(fields.length == ascending.length);
  BasicDBObject index = new BasicDBObject();
  for (int i = 0; i < fields.length; i++) {
    index.put(fields[i], ascending[i] ? 1 : -1);
  }
  IndexOptions options = new IndexOptions().partialFilterExpression(BasicDBObject.parse(filter));
  collection.createIndex(index, options);
}
origin: de.bwaldvogel/mongo-java-server-test-common

@Test
public void testAddPartialIndexOnNonIdField() {
  collection.insertOne(json("someField: 'abc'"));
  assertThat(toArray(collection.listIndexes())).hasSize(1);
  collection.createIndex(new Document("someField", 1), new IndexOptions()
    .partialFilterExpression(json("someField: {$gt: 5}")));
  assertThat(toArray(collection.listIndexes())).hasSize(2);
  collection.insertOne(json("someField: 'abc'"));
}
origin: org.wso2.extension.siddhi.store.mongodb/siddhi-store-mongodb

  break;
case "partialFilterExpression":
  indexOptions.partialFilterExpression((Bson) value);
  break;
case "collation":
origin: eclipse/ditto

/**
 * 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);
}
origin: org.eclipse.ditto/ditto-services-utils-persistence

/**
 * 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);
}
origin: org.mongodb.morphia/morphia

@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;
}
origin: hibernate/hibernate-ogm

indexOptions.partialFilterExpression( (Bson) options.get( "partialFilterExpression" ) );
origin: org.hibernate.ogm/hibernate-ogm-mongodb

indexOptions.partialFilterExpression( (Bson) options.get( "partialFilterExpression" ) );
origin: lordofthejars/nosql-unit

mongoDbIndexOptions.partialFilterExpression(indexOptions.get("partialFilterExpression", Bson.class));
origin: com.github.dadrus.jpa-unit/jpa-unit-mongodb

applyIfTrue(options.containsKey("name"), () -> indexOptions.name(options.getString("name")));
applyIfTrue(options.containsKey("partialFilterExpression"),
    () -> indexOptions.partialFilterExpression(options.get("partialFilterExpression", Bson.class)));
applyIfTrue(options.containsKey("sparse"), () -> indexOptions.sparse(options.getBoolean("sparse")));
applyIfTrue(options.containsKey("sphereVersion"), () -> indexOptions.sphereVersion(options.getInteger("sphereVersion")));
origin: SoftInstigate/restheart

ret.partialFilterExpression(options.get("partialFilterExpression")
    .asDocument());
com.mongodb.client.modelIndexOptionspartialFilterExpression

Javadoc

Sets the filter expression for the documents to be included in the index

Popular methods of IndexOptions

  • <init>
  • unique
    Should the index should be unique.
  • name
    Sets the name of the index.
  • background
    Should the index should be created in the background
  • expireAfter
    Sets the time to live for documents in the collection
  • sparse
    Should the index only references documents with the specified field
  • defaultLanguage
    Sets the language for the text index.The language that determines the list of stop words and the rul
  • languageOverride
    Sets the name of the field that contains the language string.For text indexes, the name of the field
  • weights
    Sets the weighting object for use with a text index.An document that represents field and weight pai
  • bits
    Sets the number of precision of the stored geohash value of the location data in 2d indexes.
  • getName
    Gets the name of the index.
  • isUnique
    Gets if the index should be unique.
  • getName,
  • isUnique,
  • max,
  • min,
  • sphereVersion,
  • bucketSize,
  • collation,
  • getDefaultLanguage,
  • getLanguageOverride

Popular in Java

  • Making http requests using okhttp
  • getApplicationContext (Context)
  • addToBackStack (FragmentTransaction)
  • runOnUiThread (Activity)
  • RandomAccessFile (java.io)
    Allows reading from and writing to a file in a random-access manner. This is different from the uni-
  • KeyStore (java.security)
    This class represents an in-memory collection of keys and certificates. It manages two types of entr
  • Response (javax.ws.rs.core)
    Defines the contract between a returned instance and the runtime when an application needs to provid
  • IsNull (org.hamcrest.core)
    Is the value null?
  • Loader (org.hibernate.loader)
    Abstract superclass of object loading (and querying) strategies. This class implements useful common
  • SAXParseException (org.xml.sax)
    Encapsulate an XML parse error or warning.This exception may include information for locating the er
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now