Interface FindPublisher<TResult>
-
- Type Parameters:
TResult
- The type of the result.
- All Superinterfaces:
org.reactivestreams.Publisher<TResult>
public interface FindPublisher<TResult> extends org.reactivestreams.Publisher<TResult>
Publisher interface for find.- Since:
- 1.0
-
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description FindPublisher<TResult>
allowDiskUse(Boolean allowDiskUse)
Enables writing to temporary files on the server.FindPublisher<TResult>
batchSize(int batchSize)
Sets the number of documents to return per batch.FindPublisher<TResult>
collation(Collation collation)
Sets the collation optionsFindPublisher<TResult>
comment(String comment)
Sets the comment to the query.FindPublisher<TResult>
cursorType(CursorType cursorType)
Sets the cursor type.org.reactivestreams.Publisher<Document>
explain()
Explain the execution plan for this operation with the server's default verbosity levelorg.reactivestreams.Publisher<Document>
explain(ExplainVerbosity verbosity)
Explain the execution plan for this operation with the given verbosity level<E> org.reactivestreams.Publisher<E>
explain(Class<E> explainResultClass)
Explain the execution plan for this operation with the server's default verbosity level<E> org.reactivestreams.Publisher<E>
explain(Class<E> explainResultClass, ExplainVerbosity verbosity)
Explain the execution plan for this operation with the given verbosity levelFindPublisher<TResult>
filter(Bson filter)
Sets the query filter to apply to the query.org.reactivestreams.Publisher<TResult>
first()
Helper to return a publisher limited to the first result.FindPublisher<TResult>
hint(Bson hint)
Sets the hint for which index to use.FindPublisher<TResult>
hintString(String hint)
Sets the hint for which index to use.FindPublisher<TResult>
limit(int limit)
Sets the limit to apply.FindPublisher<TResult>
max(Bson max)
Sets the exclusive upper bound for a specific index.FindPublisher<TResult>
maxAwaitTime(long maxAwaitTime, TimeUnit timeUnit)
The maximum amount of time for the server to wait on new documents to satisfy a tailable cursor query.FindPublisher<TResult>
maxTime(long maxTime, TimeUnit timeUnit)
Sets the maximum execution time on the server for this operation.FindPublisher<TResult>
min(Bson min)
Sets the minimum inclusive lower bound for a specific index.FindPublisher<TResult>
noCursorTimeout(boolean noCursorTimeout)
The server normally times out idle cursors after an inactivity period (10 minutes) to prevent excess memory use.FindPublisher<TResult>
oplogReplay(boolean oplogReplay)
Deprecated.oplogReplay has been deprecated in MongoDB 4.4.FindPublisher<TResult>
partial(boolean partial)
Get partial results from a sharded cluster if one or more shards are unreachable (instead of throwing an error).FindPublisher<TResult>
projection(Bson projection)
Sets a document describing the fields to return for all matching documents.FindPublisher<TResult>
returnKey(boolean returnKey)
Sets the returnKey.FindPublisher<TResult>
showRecordId(boolean showRecordId)
Sets the showRecordId.FindPublisher<TResult>
skip(int skip)
Sets the number of documents to skip.FindPublisher<TResult>
sort(Bson sort)
Sets the sort criteria to apply to the query.
-
-
-
Method Detail
-
first
org.reactivestreams.Publisher<TResult> first()
Helper to return a publisher limited to the first result.- Returns:
- a Publisher which will contain a single item.
-
filter
FindPublisher<TResult> filter(@Nullable Bson filter)
Sets the query filter to apply to the query.- Parameters:
filter
- the filter, which may be null.- Returns:
- this
- MongoDB documentation
- Filter
-
limit
FindPublisher<TResult> limit(int limit)
Sets the limit to apply.- Parameters:
limit
- the limit- Returns:
- this
- MongoDB documentation
- Limit
-
skip
FindPublisher<TResult> skip(int skip)
Sets the number of documents to skip.- Parameters:
skip
- the number of documents to skip- Returns:
- this
- MongoDB documentation
- Skip
-
maxTime
FindPublisher<TResult> maxTime(long maxTime, TimeUnit timeUnit)
Sets the maximum execution time on the server for this operation.- Parameters:
maxTime
- the max timetimeUnit
- the time unit, which may not be null- Returns:
- this
- MongoDB documentation
- Max Time
-
maxAwaitTime
FindPublisher<TResult> maxAwaitTime(long maxAwaitTime, TimeUnit timeUnit)
The 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:
maxAwaitTime
- the max await timetimeUnit
- the time unit to return the result in- Returns:
- the maximum await execution time in the given time unit
- Since:
- 1.2
- MongoDB documentation
- Max Time
-
projection
FindPublisher<TResult> projection(@Nullable Bson projection)
Sets 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
-
sort
FindPublisher<TResult> sort(@Nullable Bson sort)
Sets the sort criteria to apply to the query.- Parameters:
sort
- the sort criteria, which may be null.- Returns:
- this
- MongoDB documentation
- Sort
-
noCursorTimeout
FindPublisher<TResult> noCursorTimeout(boolean noCursorTimeout)
The 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
-
oplogReplay
@Deprecated FindPublisher<TResult> oplogReplay(boolean oplogReplay)
Deprecated.oplogReplay has been deprecated in MongoDB 4.4.Users should not set this under normal circumstances.- Parameters:
oplogReplay
- if oplog replay is enabled- Returns:
- this
-
partial
FindPublisher<TResult> partial(boolean 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
-
cursorType
FindPublisher<TResult> cursorType(CursorType cursorType)
Sets the cursor type.- Parameters:
cursorType
- the cursor type- Returns:
- this
-
collation
FindPublisher<TResult> collation(@Nullable Collation collation)
Sets the collation optionsA null value represents the server default.
- Parameters:
collation
- the collation options to use- Returns:
- this
- Since:
- 1.3
- Since server release
- 3.4
-
comment
FindPublisher<TResult> comment(@Nullable String comment)
Sets the comment to the query. A null value means no comment is set.- Parameters:
comment
- the comment- Returns:
- this
- Since:
- 1.6
-
hint
FindPublisher<TResult> hint(@Nullable Bson hint)
Sets the hint for which index to use. A null value means no hint is set.- Parameters:
hint
- the hint- Returns:
- this
- Since:
- 1.6
-
hintString
FindPublisher<TResult> hintString(@Nullable String hint)
Sets the hint for which index to use. A null value means no hint is set.- Parameters:
hint
- the name of the index which should be used for the operation- Returns:
- this
- Since:
- 1.13
-
max
FindPublisher<TResult> max(@Nullable Bson max)
Sets the exclusive upper bound for a specific index. A null value means no max is set.- Parameters:
max
- the max- Returns:
- this
- Since:
- 1.6
-
min
FindPublisher<TResult> min(@Nullable Bson min)
Sets the minimum inclusive lower bound for a specific index. A null value means no max is set.- Parameters:
min
- the min- Returns:
- this
- Since:
- 1.6
-
returnKey
FindPublisher<TResult> returnKey(boolean returnKey)
Sets the returnKey. If true the find operation will return only the index keys in the resulting documents.- Parameters:
returnKey
- the returnKey- Returns:
- this
- Since:
- 1.6
-
showRecordId
FindPublisher<TResult> showRecordId(boolean showRecordId)
Sets the showRecordId. Set to true to add a field$recordId
to the returned documents.- Parameters:
showRecordId
- the showRecordId- Returns:
- this
- Since:
- 1.6
-
batchSize
FindPublisher<TResult> batchSize(int batchSize)
Sets the number of documents to return per batch.Overrides the
Subscription.request(long)
value for setting the batch size, allowing for fine grained control over the underlying cursor.- Parameters:
batchSize
- the batch size- Returns:
- this
- Since:
- 1.8
- MongoDB documentation
- Batch Size
-
allowDiskUse
FindPublisher<TResult> allowDiskUse(@Nullable Boolean 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. This option is sent only if the caller explicitly sets it to true.- Parameters:
allowDiskUse
- the allowDiskUse- Returns:
- this
- Since:
- 4.1
- Since server release
- 4.4
-
explain
org.reactivestreams.Publisher<Document> explain()
Explain the execution plan for this operation with the server's default verbosity level- Returns:
- the execution plan
- Since:
- 4.2
- MongoDB documentation
- reference/command/explain/
- Since server release
- 3.2
-
explain
org.reactivestreams.Publisher<Document> explain(ExplainVerbosity verbosity)
Explain the execution plan for this operation with the given verbosity level- Parameters:
verbosity
- the verbosity of the explanation- Returns:
- the execution plan
- Since:
- 4.2
- MongoDB documentation
- reference/command/explain/
- Since server release
- 3.2
-
explain
<E> org.reactivestreams.Publisher<E> explain(Class<E> explainResultClass)
Explain the execution plan for this operation with the server's default verbosity level- Type Parameters:
E
- the type of the document class- Parameters:
explainResultClass
- the document class to decode into- Returns:
- the execution plan
- Since:
- 4.2
- MongoDB documentation
- reference/command/explain/
- Since server release
- 3.2
-
explain
<E> org.reactivestreams.Publisher<E> explain(Class<E> explainResultClass, ExplainVerbosity verbosity)
Explain the execution plan for this operation with the given verbosity level- Type Parameters:
E
- the type of the document class- Parameters:
explainResultClass
- the document class to decode intoverbosity
- the verbosity of the explanation- Returns:
- the execution plan
- Since:
- 4.2
- MongoDB documentation
- reference/command/explain/
- Since server release
- 3.2
-
-