Package com.mongodb.client.model.search
Interface SearchOptions
- All Superinterfaces:
Bson
Represents optional fields of the
$search pipeline stage of an aggregation pipeline.- Since:
- 4.7
- See Also:
- MongoDB Atlas documentation
- $search syntax
-
Field Summary
Fields inherited from interface org.bson.conversions.Bson
DEFAULT_CODEC_REGISTRY -
Method Summary
Modifier and TypeMethodDescriptioncount(SearchCount option) Creates a newSearchOptionswith the counting options specified.highlight(SearchHighlight option) Creates a newSearchOptionswith the highlighting options specified.Creates a newSearchOptionswith the index name specified.Creates a newSearchOptionswith the specified option in situations when there is no builder method that better satisfies your needs.returnStoredSource(boolean returnStoredSource) Creates a newSearchOptionsthat instruct to return only stored source fields.static SearchOptionsReturnsSearchOptionsthat represents server defaults.Methods inherited from interface org.bson.conversions.Bson
toBsonDocument, toBsonDocument
-
Method Details
-
index
Creates a newSearchOptionswith the index name specified.- Parameters:
name- The name of the index to use.- Returns:
- A new
SearchOptions.
-
highlight
Creates a newSearchOptionswith the highlighting options specified.- Parameters:
option- The highlighting option.- Returns:
- A new
SearchOptions.
-
count
Creates a newSearchOptionswith the counting options specified.- Parameters:
option- The counting option.- Returns:
- A new
SearchOptions.
-
returnStoredSource
Creates a newSearchOptionsthat 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
Creates a newSearchOptionswith 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 equivalentSearchOptionsobjects, 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
ReturnsSearchOptionsthat represents server defaults.- Returns:
SearchOptionsthat represents server defaults.
-