Package dev.morphia.query
Class FindOptions
java.lang.Object
dev.morphia.query.FindOptions
- All Implemented Interfaces:
dev.morphia.internal.CollectionConfigurable<FindOptions>
,dev.morphia.internal.CollectionConfiguration
,dev.morphia.internal.ReadConfigurable<FindOptions>
public final class FindOptions
extends Object
implements dev.morphia.internal.ReadConfigurable<FindOptions>, dev.morphia.internal.CollectionConfigurable<FindOptions>
The options to apply to a find operation (also commonly referred to as a query).
- Since:
- 1.3
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionallowDiskUse
(Boolean allowDiskUse) Enables writing to temporary files on the server.batchSize
(int batchSize) Sets the batch sizeSets the collation to usecollection
(String collection) Sets the alternate collection to use for the operation.Sets the comment to log with the querySets the comment to log with the querycursorType
(CursorType cursorType) Sets the cursor typeDefines the index hint valueSets the index hinthintString
(String hint) Defines the index hint valueAdd top-level variables to the operation.limit
(int limit) Sets the limitlogQuery()
This is an experimental method.Sets the max index valuemaxAwaitTime
(long maxAwaitTime, TimeUnit timeUnit) Sets the max await timeSets the max timeSets the min index valuenoCursorTimeout
(boolean noCursorTimeout) Sets whether to disable cursor time outoplogReplay
(boolean oplogReplay) Deprecated.removed from the driverpartial
(boolean partial) Get partial results from a sharded cluster if one or more shards are unreachable (instead of throwing an error).readConcern
(ReadConcern readConcern) Sets the read concern to applyreadPreference
(ReadPreference readPreference) Sets the read preference to applyreturnKey
(boolean returnKey) Sets if only the key value should be returnedshowRecordId
(boolean showRecordId) Sets if the record ID should be returnedskip
(int skip) Sets how many documents to skipSets to the sort to useSets to the sort to useSets to the sort to useSets to the sort to use
-
Constructor Details
-
FindOptions
public FindOptions()
-
-
Method Details
-
allowDiskUse
Enables writing to temporary files on the server. When set to true, the server can write temporary data to disk while executing the find operation.- Parameters:
allowDiskUse
- true to allow disk use- Returns:
- this
- Since:
- 2.2
-
batchSize
Sets the batch size- Parameters:
batchSize
- the size- Returns:
- this
-
collation
Sets the collation to use- Parameters:
collation
- the collation- Returns:
- this
-
collection
Sets the alternate collection to use for the operation.- Specified by:
collection
in interfacedev.morphia.internal.CollectionConfigurable<FindOptions>
- Parameters:
collection
- the name of the collection to use- Returns:
- this
-
comment
Sets the comment to log with the query- Parameters:
comment
- the comment- Returns:
- this
-
comment
Sets the comment to log with the query- Parameters:
comment
- the comment- Returns:
- this
-
cursorType
Sets the cursor type- Parameters:
cursorType
- the type- Returns:
- this
-
hint
Sets the index hint- Parameters:
hint
- the hint- Returns:
- this
-
hint
Defines the index hint value- Parameters:
hint
- the hint- Returns:
- this
-
hintString
Defines the index hint value- Parameters:
hint
- the hint- Returns:
- this
-
let
Add top-level variables to the operation. A null value means no variables are set.Allows for improved command readability by separating the variables from the query text.
- Parameters:
variables
- for find operation or null- Returns:
- this
- Since:
- 2.3
-
limit
Sets the limit- Parameters:
limit
- the limit- Returns:
- this
-
logQuery
This is an experimental method. It's implementation and presence are subject to change.- Returns:
- this
-
max
Sets the max index value- Parameters:
max
- the max- Returns:
- this
-
maxAwaitTime
Sets the max await time- Parameters:
maxAwaitTime
- the maxtimeUnit
- the unit- Returns:
- this
-
maxTime
Sets the max time- Parameters:
maxTime
- the maxtimeUnit
- the unit- Returns:
- this
-
min
Sets the min index value- Parameters:
min
- the min- Returns:
- this
-
noCursorTimeout
Sets whether to disable cursor time out- Parameters:
noCursorTimeout
- true if the time should be disabled- Returns:
- this
-
oplogReplay
Deprecated.removed from the driverUsers should not set this under normal circumstances.- Parameters:
oplogReplay
- if oplog replay is enabled- Returns:
- this
-
partial
Get 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
-
readConcern
Sets the read concern to apply- Specified by:
readConcern
in interfacedev.morphia.internal.ReadConfigurable<FindOptions>
- Parameters:
readConcern
- the read concern- Returns:
- this
-
readPreference
Sets the read preference to apply- Specified by:
readPreference
in interfacedev.morphia.internal.ReadConfigurable<FindOptions>
- Parameters:
readPreference
- the read preference- Returns:
- this
-
returnKey
Sets if only the key value should be returned- Parameters:
returnKey
- true if only the key should be returned- Returns:
- this
-
showRecordId
Sets if the record ID should be returned- Parameters:
showRecordId
- true if the record id should be returned- Returns:
- this
-
skip
Sets how many documents to skip- Parameters:
skip
- the count- Returns:
- this
-
sort
Sets to the sort to use- Parameters:
meta
- the meta data to sort by- Returns:
- this
- Since:
- 2.0
-
sort
Sets to the sort to use- Parameters:
meta
- the meta data to sort bysorts
- additional sort elements- Returns:
- this
- Since:
- 2.4
-
sort
Sets to the sort to use- Parameters:
sort
- the sort document- Returns:
- this
-
sort
Sets to the sort to use- Parameters:
sorts
- the sorts to apply- Returns:
- this
-