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 newSearchOptions
with the counting options specified.highlight
(SearchHighlight option) Creates a newSearchOptions
with the highlighting options specified.Creates a newSearchOptions
with the index name specified.Creates a newSearchOptions
with the specified option in situations when there is no builder method that better satisfies your needs.returnStoredSource
(boolean returnStoredSource) Creates a newSearchOptions
that instruct to return only stored source fields.static SearchOptions
ReturnsSearchOptions
that represents server defaults.Methods inherited from interface org.bson.conversions.Bson
toBsonDocument, toBsonDocument
-
Method Details
-
index
Creates a newSearchOptions
with the index name specified.- Parameters:
name
- The name of the index to use.- Returns:
- A new
SearchOptions
.
-
highlight
Creates a newSearchOptions
with the highlighting options specified.- Parameters:
option
- The highlighting option.- Returns:
- A new
SearchOptions
.
-
count
Creates a newSearchOptions
with the counting options specified.- Parameters:
option
- The counting option.- Returns:
- A new
SearchOptions
.
-
returnStoredSource
Creates a newSearchOptions
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
Creates a newSearchOptions
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 equivalentSearchOptions
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
ReturnsSearchOptions
that represents server defaults.- Returns:
SearchOptions
that represents server defaults.
-