Class IndexOptions
-
- com.mongodb.client.model.IndexOptions
-
public class IndexOptions extends
The options to apply to the creation of an index.- Since:
- 3.0
- MongoDB documentation
-
-
Constructor Summary
Constructors Constructor Description IndexOptions()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description IndexOptions
background(boolean background)
Should the index should be created in the backgroundIndexOptions
bits)
Sets the number of precision of the stored geohash value of the location data in 2d indexes.IndexOptions
bucketSize)
Sets the specified the number of units within which to group the location values for geoHaystack IndexesIndexOptions
collation(Collation collation)
Sets the collation optionsIndexOptions
defaultLanguage)
Sets the language for the text index.IndexOptions
expireAfter, timeUnit)
Sets the time to live for documents in the collectiongetBits()
Gets the number of precision of the stored geohash value of the location data in 2d indexes.getBucketSize()
Gets the specified the number of units within which to group the location values for geoHaystack IndexesCollation
getCollation()
Returns the collation optionsgetDefaultLanguage()
Gets the language for a text index.timeUnit)
Gets the time to live for documents in the collectiongetLanguageOverride()
Gets the name of the field that contains the language string.getMax()
Gets the upper inclusive boundary for the longitude and latitude values for 2d indexes..getMin()
Gets the lower inclusive boundary for the longitude and latitude values for 2d indexes..getName()
Gets the name of the index.Bson
getPartialFilterExpression()
Get the filter expression for the documents to be included in the index or null if not setgetSphereVersion()
Gets the 2dsphere index version number.Bson
getStorageEngine()
Gets the storage engine options document for this index.getTextVersion()
The text index version number.getVersion()
Gets the index version number.Bson
getWeights()
Gets the weighting object for use with a text indexBson
getWildcardProjection()
Gets the wildcard projection of a wildcard indexboolean
isBackground()
Create the index in the backgroundboolean
isSparse()
If true, the index only references documents with the specified fieldboolean
isUnique()
Gets if the index should be unique.IndexOptions
languageOverride)
Sets the name of the field that contains the language string.IndexOptions
max)
Sets the upper inclusive boundary for the longitude and latitude values for 2d indexes..IndexOptions
min)
Sets the lower inclusive boundary for the longitude and latitude values for 2d indexes..IndexOptions
name)
Sets the name of the index.IndexOptions
partialFilterExpression(Bson partialFilterExpression)
Sets the filter expression for the documents to be included in the indexIndexOptions
sparse(boolean sparse)
Should the index only references documents with the specified fieldIndexOptions
sphereVersion)
Sets the 2dsphere index version number.IndexOptions
storageEngine(Bson storageEngine)
Sets the storage engine options document for this index.IndexOptions
textVersion)
Set the text index version number.toString()
IndexOptions
unique(boolean unique)
Should the index should be unique.IndexOptions
version)
Sets the index version number.IndexOptions
weights(Bson weights)
Sets the weighting object for use with a text index.IndexOptions
wildcardProjection(Bson wildcardProjection)
Sets the wildcard projection of a wildcard index
-
-
-
Method Detail
-
isBackground
public boolean isBackground()
Create the index in the background- Returns:
- true if should create the index in the background
-
background
public IndexOptions background(boolean background)
Should the index should be created in the background- Parameters:
background
- true if should create the index in the background- Returns:
- this
-
isUnique
public boolean isUnique()
Gets if the index should be unique.- Returns:
- true if the index should be unique
-
unique
public IndexOptions unique(boolean unique)
Should the index should be unique.- Parameters:
unique
- if the index should be unique- Returns:
- this
-
getName
@Nullable public getName()
Gets the name of the index.- Returns:
- the name of the index
-
name
public IndexOptions name(@Nullable name)
Sets the name of the index.- Parameters:
name
- of the index- Returns:
- this
-
isSparse
public 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
-
sparse
public IndexOptions sparse(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
-
getExpireAfter
@Nullable public getExpireAfter( timeUnit)
Gets the time to live for documents in the collection- Parameters:
timeUnit
- the time unit- Returns:
- the time to live for documents in the collection
- MongoDB documentation
-
expireAfter
public IndexOptions expireAfter(@Nullable expireAfter, timeUnit)
Sets the time to live for documents in the collection- Parameters:
expireAfter
- the time to live for documents in the collectiontimeUnit
- the time unit for expireAfter- Returns:
- this
- MongoDB documentation
-
getVersion
@Nullable public getVersion()
Gets the index version number.- Returns:
- the index version number
-
version
public IndexOptions version(@Nullable version)
Sets the index version number.- Parameters:
version
- the index version number- Returns:
- this
-
getWeights
@Nullable public Bson getWeights()
Gets the weighting object for use with a text indexA 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
-
weights
public IndexOptions weights(@Nullable Bson 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
-
getDefaultLanguage
@Nullable public 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
-
defaultLanguage
public IndexOptions defaultLanguage(@Nullable 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
-
getLanguageOverride
@Nullable public 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
-
languageOverride
public IndexOptions languageOverride(@Nullable 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
-
getTextVersion
@Nullable public getTextVersion()
The text index version number.- Returns:
- the text index version number.
-
textVersion
public IndexOptions textVersion(@Nullable textVersion)
Set the text index version number.- Parameters:
textVersion
- the text index version number.- Returns:
- this
-
getSphereVersion
@Nullable public getSphereVersion()
Gets the 2dsphere index version number.- Returns:
- the 2dsphere index version number
-
sphereVersion
public IndexOptions sphereVersion(@Nullable sphereVersion)
Sets the 2dsphere index version number.- Parameters:
sphereVersion
- the 2dsphere index version number.- Returns:
- this
-
getBits
@Nullable public 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
-
bits
public IndexOptions bits(@Nullable 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
-
getMin
@Nullable public 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.
-
min
public IndexOptions min(@Nullable 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
-
getMax
@Nullable public 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.
-
max
public IndexOptions max(@Nullable 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
-
getBucketSize
@Nullable public 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
-
bucketSize
public IndexOptions bucketSize(@Nullable 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
-
getStorageEngine
@Nullable public Bson getStorageEngine()
Gets the storage engine options document for this index.- Returns:
- the storage engine options
- Since server release
-
storageEngine
public IndexOptions storageEngine(@Nullable Bson storageEngine)
Sets the storage engine options document for this index.- Parameters:
storageEngine
- the storage engine options- Returns:
- this
- Since server release
-
getPartialFilterExpression
@Nullable public Bson 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
-
partialFilterExpression
public IndexOptions partialFilterExpression(@Nullable Bson 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
-
getCollation
@Nullable public Collation getCollation()
Returns the collation options- Returns:
- the collation options
- Since:
- 3.4
- Since server release
-
collation
public IndexOptions collation(@Nullable Collation collation)
Sets the collation optionsA null value represents the server default.
- Parameters:
collation
- the collation options to use- Returns:
- this
- Since:
- 3.4
- Since server release
-
getWildcardProjection
public Bson getWildcardProjection()
Gets the wildcard projection of a wildcard index- Returns:
- the wildcard projection
- Since:
- 3.10
- Since server release
-
wildcardProjection
public IndexOptions wildcardProjection(Bson wildcardProjection)
Sets the wildcard projection of a wildcard index- Parameters:
wildcardProjection
- the wildcard projection- Returns:
- this
- Since:
- 3.10
- Since server release
-
toString
public toString()
- Overrides:
in class
-
-