Class IndexOptions


  • public class IndexOptions
    extends java.lang.Object
    The options to apply to the creation of an index.
    Since:
    3.0
    MongoDB documentation
    Index options
    • Constructor Detail

      • IndexOptions

        public IndexOptions()
      • IndexOptions

        public IndexOptions​(JsonObject json)
    • Method Detail

      • setBackground

        public IndexOptions setBackground​(java.lang.Boolean background)
        Should the index should be created in the background
        Parameters:
        background - true if should create the index in the background
        Returns:
        this
      • isBackground

        public java.lang.Boolean isBackground()
        Create the index in the background
        Returns:
        true if should create the index in the background
      • setUnique

        public IndexOptions setUnique​(java.lang.Boolean unique)
        Should the index should be unique.
        Parameters:
        unique - if the index should be unique
        Returns:
        this
      • isUnique

        public java.lang.Boolean isUnique()
        Gets if the index should be unique.
        Returns:
        true if the index should be unique
      • setName

        public IndexOptions setName​(java.lang.String name)
        Sets the name of the index.
        Parameters:
        name - of the index
        Returns:
        this
      • getName

        public java.lang.String getName()
        Gets the name of the index.
        Returns:
        the name of the index
      • setSparse

        public IndexOptions setSparse​(java.lang.Boolean sparse)
        Should the index only references documents with the specified field
        Parameters:
        sparse - if true, the index only references documents with the specified field
        Returns:
        this
      • isSparse

        public java.lang.Boolean isSparse()
        If true, the index only references documents with the specified field
        Returns:
        if the index should only reference documents with the specified field
      • setExpireAfter

        public IndexOptions setExpireAfter​(java.lang.Long expireAfter)
        Sets the time to live for documents in the collection
        Parameters:
        expireAfter - the time to live for documents in the collection (in milliseconds)
        Returns:
        this
        MongoDB documentation
        TTL
      • getExpireAfter

        public java.lang.Long getExpireAfter()
        Gets the time to live for documents in the collection
        Returns:
        the time to live for documents in the collection
        MongoDB documentation
        TTL
      • setVersion

        public IndexOptions setVersion​(java.lang.Integer version)
        Sets the index version number.
        Parameters:
        version - the index version number
        Returns:
        this
      • getVersion

        public java.lang.Integer getVersion()
        Gets the index version number.
        Returns:
        the index version number
      • setWeights

        public IndexOptions setWeights​(JsonObject weights)
        Sets the weighting object for use with a text index.

        An document that represents field and weight pairs. The weight is an integer ranging from 1 to 99,999 and denotes the significance of the field relative to the other indexed fields in terms of the score.

        Parameters:
        weights - the weighting object
        Returns:
        this
        MongoDB documentation
        Control Search Results with Weights
      • getWeights

        public JsonObject getWeights()
        Gets the weighting object for use with a text index

        A document that represents field and weight pairs. The weight is an integer ranging from 1 to 99,999 and denotes the significance of the field relative to the other indexed fields in terms of the score.

        Returns:
        the weighting object
        MongoDB documentation
        Control Search Results with Weights
      • setDefaultLanguage

        public IndexOptions setDefaultLanguage​(java.lang.String defaultLanguage)
        Sets the language for the text index.

        The language that determines the list of stop words and the rules for the stemmer and tokenizer.

        Parameters:
        defaultLanguage - the language for the text index.
        Returns:
        this
        MongoDB documentation
        Text Search languages
      • getDefaultLanguage

        public java.lang.String getDefaultLanguage()
        Gets the language for a text index.

        The language that determines the list of stop words and the rules for the stemmer and tokenizer.

        Returns:
        the language for a text index.
        MongoDB documentation
        Text Search languages
      • setLanguageOverride

        public IndexOptions setLanguageOverride​(java.lang.String languageOverride)
        Sets the name of the field that contains the language string.

        For text indexes, the name of the field, in the collection's documents, that contains the override language for the document.

        Parameters:
        languageOverride - the name of the field that contains the language string.
        Returns:
        this
        MongoDB documentation
        Language override
      • getLanguageOverride

        public java.lang.String getLanguageOverride()
        Gets the name of the field that contains the language string.

        For text indexes, the name of the field, in the collection's documents, that contains the override language for the document.

        Returns:
        the name of the field that contains the language string.
        MongoDB documentation
        Language override
      • setTextVersion

        public IndexOptions setTextVersion​(java.lang.Integer textVersion)
        Set the text index version number.
        Parameters:
        textVersion - the text index version number.
        Returns:
        this
      • getTextVersion

        public java.lang.Integer getTextVersion()
        The text index version number.
        Returns:
        the text index version number.
      • setSphereVersion

        public IndexOptions setSphereVersion​(java.lang.Integer sphereVersion)
        Sets the 2dsphere index version number.
        Parameters:
        sphereVersion - the 2dsphere index version number.
        Returns:
        this
      • getSphereVersion

        public java.lang.Integer getSphereVersion()
        Gets the 2dsphere index version number.
        Returns:
        the 2dsphere index version number
      • setBits

        public IndexOptions setBits​(java.lang.Integer bits)
        Sets the number of precision of the stored geohash value of the location data in 2d indexes.
        Parameters:
        bits - the number of precision of the stored geohash value
        Returns:
        this
      • getBits

        public java.lang.Integer getBits()
        Gets the number of precision of the stored geohash value of the location data in 2d indexes.
        Returns:
        the number of precision of the stored geohash value
      • setMin

        public IndexOptions setMin​(java.lang.Double min)
        Sets the lower inclusive boundary for the longitude and latitude values for 2d indexes..
        Parameters:
        min - the lower inclusive boundary for the longitude and latitude values
        Returns:
        this
      • getMin

        public java.lang.Double getMin()
        Gets the lower inclusive boundary for the longitude and latitude values for 2d indexes..
        Returns:
        the lower inclusive boundary for the longitude and latitude values.
      • setMax

        public IndexOptions setMax​(java.lang.Double max)
        Sets the upper inclusive boundary for the longitude and latitude values for 2d indexes..
        Parameters:
        max - the upper inclusive boundary for the longitude and latitude values
        Returns:
        this
      • getMax

        public java.lang.Double getMax()
        Gets the upper inclusive boundary for the longitude and latitude values for 2d indexes..
        Returns:
        the upper inclusive boundary for the longitude and latitude values.
      • setBucketSize

        public IndexOptions setBucketSize​(java.lang.Double bucketSize)
        Sets the specified the number of units within which to group the location values for geoHaystack Indexes
        Parameters:
        bucketSize - the specified the number of units within which to group the location values for geoHaystack Indexes
        Returns:
        this
        MongoDB documentation
        geoHaystack Indexes
      • getBucketSize

        public java.lang.Double getBucketSize()
        Gets the specified the number of units within which to group the location values for geoHaystack Indexes
        Returns:
        the specified the number of units within which to group the location values for geoHaystack Indexes
        MongoDB documentation
        geoHaystack Indexes
      • setStorageEngine

        public IndexOptions setStorageEngine​(JsonObject storageEngine)
        Sets the storage engine options document for this index.
        Parameters:
        storageEngine - the storage engine options
        Returns:
        this
        Since server release
        3.0
      • getStorageEngine

        public JsonObject getStorageEngine()
        Gets the storage engine options document for this index.
        Returns:
        the storage engine options
        Since server release
        3.0
      • setPartialFilterExpression

        public IndexOptions setPartialFilterExpression​(JsonObject partialFilterExpression)
        Sets the filter expression for the documents to be included in the index
        Parameters:
        partialFilterExpression - the filter expression for the documents to be included in the index
        Returns:
        this
        Since:
        3.2
        Since server release
        3.2
      • getPartialFilterExpression

        public JsonObject getPartialFilterExpression()
        Get the filter expression for the documents to be included in the index or null if not set
        Returns:
        the filter expression for the documents to be included in the index or null if not set
        Since:
        3.2
        Since server release
        3.2
      • setCollation

        public IndexOptions setCollation​(Collation collation)
        Sets the collation options

        A null value represents the server default.

        Parameters:
        collation - the collation options to use
        Returns:
        this
        Since:
        3.4
        Since server release
        3.4
      • getCollation

        public Collation getCollation()
        Returns the collation options
        Returns:
        the collation options
        Since:
        3.4
        Since server release
        3.4
      • setWildcardProjection

        public IndexOptions setWildcardProjection​(JsonObject wildcardProjection)
        Sets the wildcard projection of a wildcard index
        Parameters:
        wildcardProjection - the wildcard projection
        Returns:
        this
        Since:
        3.10
        Since server release
        4.2
      • getWildcardProjection

        public JsonObject getWildcardProjection()
        Gets the wildcard projection of a wildcard index
        Returns:
        the wildcard projection
        Since:
        3.10
        Since server release
        4.2
      • setHidden

        public IndexOptions setHidden​(java.lang.Boolean hidden)
        Should the index not be used by the query planner when executing operations.
        Parameters:
        hidden - true if the index should be hidden
        Returns:
        this
        Since:
        4.1
        Since server release
        4.4
      • isHidden

        public java.lang.Boolean isHidden()
        Gets whether the index should not be used by the query planner when executing operations.
        Returns:
        true if the index should not be used by the query planner when executing operations.
        Since:
        4.1
        Since server release
        4.4