Interface VectorSearchOptions

All Superinterfaces:
Bson
All Known Subinterfaces:
ApproximateVectorSearchOptions, ExactVectorSearchOptions

@Sealed public interface VectorSearchOptions extends Bson
Represents optional fields of the $vectorSearch pipeline stage of an aggregation pipeline.
Since:
4.11
See Also:
MongoDB Atlas documentation
$vectorSearch
Since server release
6.0.11
  • Method Details

    • filter

      VectorSearchOptions filter(Bson filter)
      Creates a new VectorSearchOptions with the filter specified.
      Parameters:
      filter - A filter that is applied before applying the queryVector One may use Filters to create this filter, though not all filters may be supported. See the MongoDB documentation for the list of supported filters.
      Returns:
      A new VectorSearchOptions.
    • option

      VectorSearchOptions option(String name, Object value)
      Creates a new VectorSearchOptions with the specified option in situations when there is no builder method that better satisfies your needs. This method cannot be used to validate the syntax.

      Example
      The following code creates two functionally equivalent VectorSearchOptions objects, though they may not be equal.

      
        VectorSearchOptions options1 = VectorSearchOptions.vectorSearchOptions()
            .filter(Filters.lt("fieldName", 1));
        VectorSearchOptions options2 = VectorSearchOptions.vectorSearchOptions()
            .option("filter", Filters.lt("fieldName", 1));
       
      Parameters:
      name - The option name.
      value - The option value.
      Returns:
      A new VectorSearchOptions.
    • approximateVectorSearchOptions

      static ApproximateVectorSearchOptions approximateVectorSearchOptions(long numCandidates)
      Returns ApproximateVectorSearchOptions that represents server defaults.
      Parameters:
      numCandidates - The number of candidates.
      Returns:
      ApproximateVectorSearchOptions that represents server defaults.
      Since:
      5.2
    • exactVectorSearchOptions

      static ExactVectorSearchOptions exactVectorSearchOptions()
      Returns ExactVectorSearchOptions that represents server defaults with the exact option set to true.
      Returns:
      ExactVectorSearchOptions that represents server defaults.
      Since:
      5.2