Package com.mongodb.client.model
Class DBCollectionFindOptions
java.lang.Object
com.mongodb.client.model.DBCollectionFindOptions
The options to apply to a find operation (also commonly referred to as a query).
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionbatchSize(int batchSize) Sets the number of documents to return per batch.Sets the collationSets the comment to the query.copy()Copy this DBCollectionFindOptions instance into a new instance.cursorType(CursorType cursorType) Sets the cursor type.intGets the number of documents to return per batch.Returns the collation optionsReturns the comment to send with the query.Get the cursor type.getHint()Returns the hint for which index to use.Returns the hint string for the name of the index to use.intgetLimit()Gets the limit to apply.getMax()Returns the exclusive upper bound for a specific index.longgetMaxAwaitTime(TimeUnit timeUnit) The maximum amount of time for the server to wait on new documents to satisfy a tailable cursor query.longgetMaxTime(TimeUnit timeUnit) Gets the maximum execution time on the server for this operation.getMin()Returns the minimum inclusive lower bound for a specific index.Gets a document describing the fields to return for all matching documents.Returns the readConcernReturns the readPreferenceintgetSkip()Gets the number of documents to skip.getSort()Gets the sort criteria to apply to the query.Sets the hint for which index to use.hintString(String hintString) Sets the hint for the name of the index to use.booleanThe server normally times out idle cursors after an inactivity period (10 minutes) to prevent excess memory use.booleanGet partial results from a sharded cluster if one or more shards are unreachable (instead of throwing an error).booleanReturns the returnKey.booleanReturns the showRecordId.limit(int limit) Sets the limit to apply.Sets the exclusive upper bound for a specific index.maxAwaitTime(long maxAwaitTime, TimeUnit timeUnit) Sets the maximum await execution time on the server for this operation.Sets the maximum execution time on the server for this operation.Sets the minimum inclusive lower bound for a specific index.noCursorTimeout(boolean noCursorTimeout) The server normally times out idle cursors after an inactivity period (10 minutes) to prevent excess memory use.partial(boolean partial) Get partial results from a sharded cluster if one or more shards are unreachable (instead of throwing an error).projection(DBObject projection) Sets a document describing the fields to return for all matching documents.readConcern(ReadConcern readConcern) Sets the readConcernreadPreference(ReadPreference readPreference) Sets the readPreferencereturnKey(boolean returnKey) Sets the returnKey.showRecordId(boolean showRecordId) Sets the showRecordId.skip(int skip) Sets the number of documents to skip.Sets the sort criteria to apply to the query.
- 
Constructor Details- 
DBCollectionFindOptionspublic DBCollectionFindOptions()Construct a new instance
 
- 
- 
Method Details- 
copyCopy this DBCollectionFindOptions instance into a new instance.- Returns:
- the new DBCollectionFindOptions with the same settings as this instance.
 
- 
getLimitpublic int getLimit()Gets the limit to apply. The default is null.- Returns:
- the limit
- MongoDB documentation
- Limit
 
- 
limitSets the limit to apply.- Parameters:
- limit- the limit
- Returns:
- this
- MongoDB documentation
- Limit
 
- 
getSkippublic int getSkip()Gets the number of documents to skip. The default is 0.- Returns:
- the number of documents to skip
- MongoDB documentation
- Skip
 
- 
skipSets the number of documents to skip.- Parameters:
- skip- the number of documents to skip
- Returns:
- this
- MongoDB documentation
- Skip
 
- 
getMaxTimeGets the maximum execution time on the server for this operation. The default is 0, which places no limit on the execution time.- Parameters:
- timeUnit- the time unit to return the result in
- Returns:
- the maximum execution time in the given time unit
- MongoDB documentation
- Max Time
 
- 
maxTimeSets the maximum execution time on the server for this operation.- Parameters:
- maxTime- the max time
- timeUnit- the time unit, which may not be null
- Returns:
- this
- MongoDB documentation
- Max Time
 
- 
getMaxAwaitTimeThe maximum amount of time for the server to wait on new documents to satisfy a tailable cursor query. This only applies to a TAILABLE_AWAIT cursor. When the cursor is not a TAILABLE_AWAIT cursor, this option is ignored.On servers >= 3.2, this option will be specified on the getMore command as "maxTimeMS". The default is no value: no "maxTimeMS" is sent to the server with the getMore command. On servers < 3.2, this option is ignored, and indicates that the driver should respect the server's default value A zero value will be ignored. - Parameters:
- timeUnit- the time unit to return the result in
- Returns:
- the maximum await execution time in the given time unit
- MongoDB documentation
- Max Time
 
- 
maxAwaitTimeSets the maximum await execution time on the server for this operation.- Parameters:
- maxAwaitTime- the max await time. A zero value will be ignored, and indicates that the driver should respect the server's default value
- timeUnit- the time unit, which may not be null
- Returns:
- this
- MongoDB documentation
- Max Time
 
- 
getBatchSizepublic int getBatchSize()Gets the number of documents to return per batch. Default to 0, which indicates that the server chooses an appropriate batch size.- Returns:
- the batch size
- MongoDB documentation
- Batch Size
 
- 
batchSizeSets the number of documents to return per batch.- Parameters:
- batchSize- the batch size
- Returns:
- this
- MongoDB documentation
- Batch Size
 
- 
getProjectionGets a document describing the fields to return for all matching documents.- Returns:
- the project document, which may be null
- MongoDB documentation
- Projection
 
- 
projectionSets a document describing the fields to return for all matching documents.- Parameters:
- projection- the project document, which may be null.
- Returns:
- this
- MongoDB documentation
- Projection
 
- 
getSortGets the sort criteria to apply to the query. The default is null, which means that the documents will be returned in an undefined order.- Returns:
- a document describing the sort criteria
- MongoDB documentation
- Sort
 
- 
sortSets the sort criteria to apply to the query.- Parameters:
- sort- the sort criteria, which may be null.
- Returns:
- this
- MongoDB documentation
- Sort
 
- 
isNoCursorTimeoutpublic boolean isNoCursorTimeout()The server normally times out idle cursors after an inactivity period (10 minutes) to prevent excess memory use. If true, that timeout is disabled.- Returns:
- true if cursor timeout is disabled
 
- 
noCursorTimeoutThe server normally times out idle cursors after an inactivity period (10 minutes) to prevent excess memory use. Set this option to prevent that.- Parameters:
- noCursorTimeout- true if cursor timeout is disabled
- Returns:
- this
 
- 
isPartialpublic boolean isPartial()Get partial results from a sharded cluster if one or more shards are unreachable (instead of throwing an error).- Returns:
- if partial results for sharded clusters is enabled
 
- 
partialGet partial results from a sharded cluster if one or more shards are unreachable (instead of throwing an error).- Parameters:
- partial- if partial results for sharded clusters is enabled
- Returns:
- this
 
- 
getCursorTypeGet the cursor type.- Returns:
- the cursor type
 
- 
cursorTypeSets the cursor type.- Parameters:
- cursorType- the cursor type
- Returns:
- this
 
- 
getReadPreferenceReturns the readPreference- Returns:
- the readPreference
 
- 
readPreferenceSets the readPreference- Parameters:
- readPreference- the readPreference
- Returns:
- this
 
- 
getReadConcernReturns the readConcern- Returns:
- the readConcern
- Since server release
- 3.2
 
- 
readConcernSets the readConcern- Parameters:
- readConcern- the readConcern
- Returns:
- this
- Since server release
- 3.2
 
- 
getCollationReturns the collation options- Returns:
- the collation options
- Since server release
- 3.4
 
- 
collationSets the collation- Parameters:
- collation- the collation
- Returns:
- this
- Since server release
- 3.4
 
- 
getCommentReturns the comment to send with the query. The default is not to include a comment with the query.- Returns:
- the comment
- Since:
- 3.9
 
- 
commentSets the comment to the query. A null value means no comment is set.- Parameters:
- comment- the comment
- Returns:
- this
- Since:
- 3.9
 
- 
getHintReturns the hint for which index to use. The default is not to set a hint.- Returns:
- the hint
- Since:
- 3.9
 
- 
getHintStringReturns the hint string for the name of the index to use. The default is not to set a hint.- Returns:
- the hint string
- Since:
- 4.4
 
- 
hintSets the hint for which index to use. A null value means no hint is set.- Parameters:
- hint- the hint
- Returns:
- this
- Since:
- 3.9
 
- 
hintStringSets the hint for the name of the index to use. A null value means no hint is set.- Parameters:
- hintString- the hint string
- Returns:
- this
- Since:
- 4.4
 
- 
getMaxReturns the exclusive upper bound for a specific index. By default there is no max bound.- Returns:
- the max
- Since:
- 3.9
 
- 
maxSets the exclusive upper bound for a specific index. A null value means no max is set.- Parameters:
- max- the max
- Returns:
- this
- Since:
- 3.9
 
- 
getMinReturns the minimum inclusive lower bound for a specific index. By default there is no min bound.- Returns:
- the min
- Since:
- 3.9
 
- 
minSets the minimum inclusive lower bound for a specific index. A null value means no max is set.- Parameters:
- min- the min
- Returns:
- this
- Since:
- 3.9
 
- 
isReturnKeypublic boolean isReturnKey()Returns the returnKey. If true the find operation will return only the index keys in the resulting documents.Default value is false. If returnKey is true and the find command does not use an index, the returned documents will be empty. - Returns:
- the returnKey
- Since:
- 3.9
 
- 
returnKeySets the returnKey. If true the find operation will return only the index keys in the resulting documents.- Parameters:
- returnKey- the returnKey
- Returns:
- this
- Since:
- 3.9
 
- 
isShowRecordIdpublic boolean isShowRecordId()Returns the showRecordId.Determines whether to return the record identifier for each document. If true, adds a field $recordId to the returned documents. The default is false. - Returns:
- the showRecordId
- Since:
- 3.9
 
- 
showRecordIdSets the showRecordId. Set to true to add a field$recordIdto the returned documents.- Parameters:
- showRecordId- the showRecordId
- Returns:
- this
- Since:
- 3.9
 
 
-