Class AggregationOptions.Builder

java.lang.Object
org.springframework.data.mongodb.core.aggregation.AggregationOptions.Builder
Enclosing class:
AggregationOptions

public static class AggregationOptions.Builder extends Object
A Builder for AggregationOptions.
Since:
1.6
Author:
Thomas Darimont, Mark Paluch
  • Constructor Details

    • Builder

      public Builder()
  • Method Details

    • allowDiskUse

      @Contract("_ -> this") public AggregationOptions.Builder allowDiskUse(boolean allowDiskUse)
      Defines whether to off-load intensive sort-operations to disk.
      Parameters:
      allowDiskUse - use true to allow disk use during the aggregation.
      Returns:
      this.
    • diskUse

      @Contract("_ -> this") public AggregationOptions.Builder diskUse(DiskUse diskUse)
      Defines whether to off-load intensive sort-operations to disk.
      Parameters:
      diskUse - use true to allow disk use during the aggregation.
      Returns:
      this.
      Since:
      5.0
    • explain

      @Contract("_ -> this") public AggregationOptions.Builder explain(boolean explain)
      Defines whether to get the execution plan for the aggregation instead of the actual results.
      Parameters:
      explain - use true to enable explain feature.
      Returns:
      this.
    • cursor

      @Contract("_ -> this") public AggregationOptions.Builder cursor(org.bson.Document cursor)
      Additional options to the aggregation.
      Parameters:
      cursor - must not be null.
      Returns:
      this.
    • cursorBatchSize

      @Contract("_ -> this") public AggregationOptions.Builder cursorBatchSize(int batchSize)
      Define the initial cursor batch size.
      Parameters:
      batchSize - use a positive int.
      Returns:
      this.
      Since:
      2.0
    • collation

      @Contract("_ -> this") public AggregationOptions.Builder collation(@Nullable Collation collation)
      Define collation settings for string comparison.
      Parameters:
      collation - can be null.
      Returns:
      this.
      Since:
      2.0
    • comment

      @Contract("_ -> this") public AggregationOptions.Builder comment(@Nullable String comment)
      Define a comment to describe the execution.
      Parameters:
      comment - can be null.
      Returns:
      this.
      Since:
      2.2
    • hint

      @Contract("_ -> this") public AggregationOptions.Builder hint(@Nullable org.bson.Document hint)
      Define a hint that is used by query optimizer to to fulfill the aggregation.
      Parameters:
      hint - can be null.
      Returns:
      this.
      Since:
      3.1
    • hint

      @Contract("_ -> this") public AggregationOptions.Builder hint(@Nullable String indexName)
      Define a hint that is used by query optimizer to to fulfill the aggregation.
      Parameters:
      indexName - can be null.
      Returns:
      this.
      Since:
      4.1
    • readConcern

      @Contract("_ -> this") public AggregationOptions.Builder readConcern(@Nullable com.mongodb.ReadConcern readConcern)
      Define a ReadConcern to apply to the aggregation.
      Parameters:
      readConcern - can be null.
      Returns:
      this.
      Since:
      4.1
    • readPreference

      @Contract("_ -> this") public AggregationOptions.Builder readPreference(@Nullable com.mongodb.ReadPreference readPreference)
      Define a ReadPreference to apply to the aggregation.
      Parameters:
      readPreference - can be null.
      Returns:
      this.
      Since:
      4.1
    • maxTime

      @Contract("_ -> this") public AggregationOptions.Builder maxTime(@Nullable Duration maxTime)
      Set the time limit for processing.
      Parameters:
      maxTime - Duration.ZERO is used for the default unbounded behavior. Negative values will be ignored.
      Returns:
      this.
      Since:
      3.0
    • skipOutput

      @Contract("-> this") public AggregationOptions.Builder skipOutput()
      Run the aggregation, but do NOT read the aggregation result from the store.
      If the expected result of the aggregation is rather large, eg. when using an $out operation, this option allows to execute the aggregation without having the cursor return the operation result.
      Returns:
      this.
      Since:
      3.0.2
    • strictMapping

      @Contract("-> this") public AggregationOptions.Builder strictMapping()
      Apply a strict domain type mapping considering Field annotations throwing errors for non-existent, but referenced fields.
      Returns:
      this.
      Since:
      3.2
    • relaxedMapping

      @Contract("-> this") public AggregationOptions.Builder relaxedMapping()
      Apply a relaxed domain type mapping considering Field annotations using the user provided name if a referenced field does not exist.
      Returns:
      this.
      Since:
      3.2
    • noMapping

      @Contract("-> this") public AggregationOptions.Builder noMapping()
      Apply no domain type mapping at all taking the pipeline as-is.
      Returns:
      this.
      Since:
      3.2
    • build

      @Contract("-> new") public AggregationOptions build()
      Returns a new AggregationOptions instance with the given configuration.
      Returns:
      new instance of AggregationOptions.