Interface SearchOptions

All Superinterfaces:
Bson

@Sealed @Beta(CLIENT) public interface SearchOptions extends Bson
Represents optional fields of the $search pipeline stage of an aggregation pipeline.
Since:
4.7
See Also:
MongoDB Atlas documentation
$search syntax
  • Method Details

    • index

      SearchOptions index(String name)
      Creates a new SearchOptions with the index name specified.
      Parameters:
      name - The name of the index to use.
      Returns:
      A new SearchOptions.
    • highlight

      SearchOptions highlight(SearchHighlight option)
      Creates a new SearchOptions with the highlighting options specified.
      Parameters:
      option - The highlighting option.
      Returns:
      A new SearchOptions.
    • count

      SearchOptions count(SearchCount option)
      Creates a new SearchOptions with the counting options specified.
      Parameters:
      option - The counting option.
      Returns:
      A new SearchOptions.
    • returnStoredSource

      SearchOptions returnStoredSource(boolean returnStoredSource)
      Creates a new SearchOptions that instruct to return only stored source fields.
      Parameters:
      returnStoredSource - The option to return only stored source fields.
      Returns:
      A new SearchOptions.
      MongoDB Atlas documentation
      Return stored source fields
    • option

      SearchOptions option(String name, Object value)
      Creates a new SearchOptions 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 SearchOptions objects, though they may not be equal.

      
        SearchOptions options1 = SearchOptions.searchOptions().index("indexName");
        SearchOptions options2 = SearchOptions.searchOptions().option("index", "indexName");
       
      Parameters:
      name - The option name.
      value - The option value.
      Returns:
      A new SearchOptions.
    • searchOptions

      static SearchOptions searchOptions()
      Returns SearchOptions that represents server defaults.
      Returns:
      SearchOptions that represents server defaults.