Class FindOptions

    • Constructor Summary

      Constructors 
      Constructor Description
      FindOptions()
      Creates an empty options instance.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      FindOptions batchSize​(int batchSize)
      Sets the number of documents to return per batch.
      FindOptions collation​(com.mongodb.client.model.Collation collation)
      Sets the collation
      FindOptions comment​(java.lang.String comment)  
      FindOptions copy()
      Makes a copy of these find options
      FindOptions cursorType​(com.mongodb.CursorType cursorType)
      Sets the cursor type.
      int getBatchSize()
      Gets the number of documents to return per batch.
      com.mongodb.client.model.Collation getCollation()
      Returns the collation options
      java.lang.String getComment()  
      com.mongodb.CursorType getCursorType()
      Get the cursor type.
      com.mongodb.DBObject getHint()  
      int getLimit()
      Gets the limit to apply.
      com.mongodb.DBObject getMax()  
      long getMaxAwaitTime​(java.util.concurrent.TimeUnit timeUnit)
      The maximum amount of time for the server to wait on new documents to satisfy a tailable cursor query.
      long getMaxTime​(java.util.concurrent.TimeUnit timeUnit)
      Gets the maximum execution time on the server for this operation.
      com.mongodb.DBObject getMin()  
      com.mongodb.ReadConcern getReadConcern()
      Returns the readConcern
      com.mongodb.ReadPreference getReadPreference()
      Returns the readPreference
      int getSkip()
      Gets the number of documents to skip.
      com.mongodb.DBObject getSort()  
      FindOptions hint​(com.mongodb.DBObject hint)  
      FindOptions hintString​(java.lang.String hint)
      Defines the index hint value
      boolean isNoCursorTimeout()
      The server normally times out idle cursors after an inactivity period (10 minutes) to prevent excess memory use.
      boolean isOplogReplay()
      Users should not set this under normal circumstances.
      boolean isPartial()
      Get partial results from a sharded cluster if one or more shards are unreachable (instead of throwing an error).
      boolean isReturnKey()  
      boolean isShowRecordId()  
      FindOptions limit​(int limit)
      Sets the limit to apply.
      FindOptions max​(com.mongodb.DBObject max)  
      FindOptions maxAwaitTime​(long maxAwaitTime, java.util.concurrent.TimeUnit timeUnit)
      Sets the maximum await execution time on the server for this operation.
      FindOptions maxTime​(long maxTime, java.util.concurrent.TimeUnit timeUnit)
      Sets the maximum execution time on the server for this operation.
      FindOptions min​(com.mongodb.DBObject min)  
      FindOptions noCursorTimeout​(boolean noCursorTimeout)
      The server normally times out idle cursors after an inactivity period (10 minutes) to prevent excess memory use.
      FindOptions oplogReplay​(boolean oplogReplay)
      Users should not set this under normal circumstances.
      FindOptions partial​(boolean partial)
      Get partial results from a sharded cluster if one or more shards are unreachable (instead of throwing an error).
      FindOptions readConcern​(com.mongodb.ReadConcern readConcern)
      Sets the readConcern
      FindOptions readPreference​(com.mongodb.ReadPreference readPreference)
      Sets the readPreference
      FindOptions returnKey​(boolean returnKey)  
      FindOptions showRecordId​(boolean showRecordId)  
      FindOptions skip​(int skip)
      Sets the number of documents to skip.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • FindOptions

        public FindOptions()
        Creates an empty options instance.
    • Method Detail

      • collation

        public FindOptions collation​(com.mongodb.client.model.Collation collation)
        Sets the collation
        Parameters:
        collation - the collation
        Returns:
        this
        Since server release
        3.4
      • comment

        public FindOptions comment​(java.lang.String comment)
      • copy

        public FindOptions copy()
        Makes a copy of these find options
        Returns:
        the new copy
      • cursorType

        public FindOptions cursorType​(com.mongodb.CursorType cursorType)
        Sets the cursor type.
        Parameters:
        cursorType - the cursor type
        Returns:
        this
      • getCollation

        public com.mongodb.client.model.Collation getCollation()
        Returns the collation options
        Returns:
        the collation options
        Since server release
        3.4
      • getComment

        @Nullable
        public java.lang.String getComment()
      • getCursorType

        public com.mongodb.CursorType getCursorType()
        Get the cursor type.
        Returns:
        the cursor type
      • getHint

        @Nullable
        public com.mongodb.DBObject getHint()
      • getMax

        @Nullable
        public com.mongodb.DBObject getMax()
      • getMaxAwaitTime

        public long getMaxAwaitTime​(java.util.concurrent.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:
        timeUnit - the time unit to return the result in
        Returns:
        the maximum await execution time in the given time unit
        MongoDB documentation
        reference/method/cursor.maxTimeMS/#cursor.maxTimeMS Max Time
      • getMaxTime

        public long getMaxTime​(java.util.concurrent.TimeUnit timeUnit)
        Gets 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
        reference/method/cursor.maxTimeMS/#cursor.maxTimeMS Max Time
      • getMin

        @Nullable
        public com.mongodb.DBObject getMin()
      • getReadConcern

        public com.mongodb.ReadConcern getReadConcern()
        Returns the readConcern
        Returns:
        the readConcern
        Since server release
        3.2
      • getReadPreference

        public com.mongodb.ReadPreference getReadPreference()
        Returns the readPreference
        Returns:
        the readPreference
      • getSort

        @Nullable
        public com.mongodb.DBObject getSort()
      • hint

        public FindOptions hint​(com.mongodb.DBObject hint)
      • hintString

        public FindOptions hintString​(java.lang.String hint)
        Defines the index hint value
        Parameters:
        hint - the hint
        Returns:
        this
      • isNoCursorTimeout

        public 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
      • isOplogReplay

        public boolean isOplogReplay()
        Users should not set this under normal circumstances.
        Returns:
        if oplog replay is enabled
      • isPartial

        public 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
      • isReturnKey

        public boolean isReturnKey()
      • isShowRecordId

        public boolean isShowRecordId()
      • max

        public FindOptions max​(com.mongodb.DBObject max)
      • maxAwaitTime

        public FindOptions maxAwaitTime​(long maxAwaitTime,
                                        java.util.concurrent.TimeUnit timeUnit)
        Sets 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
        reference/method/cursor.maxTimeMS/#cursor.maxTimeMS Max Time
      • min

        public FindOptions min​(com.mongodb.DBObject min)
      • noCursorTimeout

        public FindOptions 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

        public FindOptions oplogReplay​(boolean oplogReplay)
        Users should not set this under normal circumstances.
        Parameters:
        oplogReplay - if oplog replay is enabled
        Returns:
        this
      • partial

        public FindOptions 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
      • readConcern

        public FindOptions readConcern​(com.mongodb.ReadConcern readConcern)
        Sets the readConcern
        Parameters:
        readConcern - the readConcern
        Returns:
        this
        Since server release
        3.2
      • readPreference

        public FindOptions readPreference​(com.mongodb.ReadPreference readPreference)
        Sets the readPreference
        Parameters:
        readPreference - the readPreference
        Returns:
        this
      • returnKey

        public FindOptions returnKey​(boolean returnKey)
      • showRecordId

        public FindOptions showRecordId​(boolean showRecordId)