object SearchOperator
The core part of the $search
pipeline stage of an aggregation pipeline.
- Annotations
- @Beta()
- Since
4.7
- See also
- Alphabetic
- By Inheritance
- SearchOperator
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Value Members
- def autocomplete(path: FieldSearchPath, queries: Iterable[String]): AutocompleteSearchOperator
Returns a
SearchOperator
that may be used to implement search-as-you-type functionality.Returns a
SearchOperator
that may be used to implement search-as-you-type functionality.- path
The field to be searched.
- queries
The non-empty strings to search for.
- returns
The requested
SearchOperator
.
- See also
- def autocomplete(path: FieldSearchPath, query: String, queries: String*): AutocompleteSearchOperator
Returns a
SearchOperator
that may be used to implement search-as-you-type functionality.Returns a
SearchOperator
that may be used to implement search-as-you-type functionality.- path
The field to be searched.
- query
The string to search for.
- queries
More strings to search for.
- returns
The requested
SearchOperator
.
- See also
- def compound(): CompoundSearchOperatorBase
Returns a base for a
SearchOperator
that may combine multipleSearchOperator
s.Returns a base for a
SearchOperator
that may combine multipleSearchOperator
s. CombiningSearchOperator
s affects calculation of the relevance score.- returns
A base for a
CompoundSearchOperator
.
- See also
- def dateRange(paths: Iterable[_ <: FieldSearchPath]): DateRangeSearchOperatorBase
Returns a base for a
SearchOperator
that tests if the BSONDate
values of the specified fields are within an interval.Returns a base for a
SearchOperator
that tests if the BSONDate
values of the specified fields are within an interval.- paths
The non-empty fields to be searched.
- returns
A base for a
DateRangeSearchOperator
.
- See also
- def dateRange(path: FieldSearchPath, paths: FieldSearchPath*): DateRangeSearchOperatorBase
Returns a base for a
SearchOperator
that tests if the BSONDate
values of the specified fields are within an interval.Returns a base for a
SearchOperator
that tests if the BSONDate
values of the specified fields are within an interval.- path
The field to be searched.
- paths
More fields to be searched.
- returns
A base for a
DateRangeSearchOperator
.
- See also
- def equals(path: FieldSearchPath, value: UUID): EqualsSearchOperator
Returns a
SearchOperator
that searches for documents where a field matches the specified value.Returns a
SearchOperator
that searches for documents where a field matches the specified value.- path
The indexed field to be searched.
- value
The uuid value to query for.
- returns
The requested
SearchOperator
.
- See also
- def equals(path: FieldSearchPath, value: String): EqualsSearchOperator
Returns a
SearchOperator
that searches for documents where a field matches the specified value.Returns a
SearchOperator
that searches for documents where a field matches the specified value.- path
The indexed field to be searched.
- value
The string value to query for.
- returns
The requested
SearchOperator
.
- See also
- def equals(path: FieldSearchPath, value: Instant): EqualsSearchOperator
Returns a
SearchOperator
that searches for documents where a field matches the specified value.Returns a
SearchOperator
that searches for documents where a field matches the specified value.- path
The indexed field to be searched.
- value
The instant date value to query for.
- returns
The requested
SearchOperator
.
- See also
- def equals(path: FieldSearchPath, value: Number): EqualsSearchOperator
Returns a
SearchOperator
that searches for documents where a field matches the specified value.Returns a
SearchOperator
that searches for documents where a field matches the specified value.- path
The indexed field to be searched.
- value
The number value to query for.
- returns
The requested
SearchOperator
.
- See also
- def equals(path: FieldSearchPath, value: ObjectId): EqualsSearchOperator
Returns a
SearchOperator
that searches for documents where a field matches the specified value.Returns a
SearchOperator
that searches for documents where a field matches the specified value.- path
The indexed field to be searched.
- value
The object id value to query for.
- returns
The requested
SearchOperator
.
- See also
- def equals(path: FieldSearchPath, value: Boolean): EqualsSearchOperator
Returns a
SearchOperator
that searches for documents where a field matches the specified value.Returns a
SearchOperator
that searches for documents where a field matches the specified value.- path
The indexed field to be searched.
- value
The boolean value to query for.
- returns
The requested
SearchOperator
.
- See also
- def equalsNull(path: FieldSearchPath): EqualsSearchOperator
Returns a
SearchOperator
that searches for documents where a field matches null.Returns a
SearchOperator
that searches for documents where a field matches null.- path
The indexed field to be searched.
- returns
The requested
SearchOperator
.
- See also
- def exists(path: FieldSearchPath): ExistsSearchOperator
Returns a
SearchOperator
that tests if thepath
exists in a document.Returns a
SearchOperator
that tests if thepath
exists in a document.- path
The path to test.
- returns
The requested
SearchOperator
.
- See also
- def in[T](path: FieldSearchPath, values: Iterable[_ <: T]): InSearchOperator
Returns a
SearchOperator
that searches for documents where the value or array of values at a given path contains any of the specified valuesReturns a
SearchOperator
that searches for documents where the value or array of values at a given path contains any of the specified values- path
The indexed field to be searched.
- values
The non-empty values to search for. Value can be either a single value or an array of values of only one of the supported BSON types and can't be a mix of different types.
- returns
The requested
SearchOperator
.
- See also
- def in(path: FieldSearchPath, value: String, values: String*): InSearchOperator
Returns a
SearchOperator
that searches for documents where the value or array of values at a given path contains any of the specified valuesReturns a
SearchOperator
that searches for documents where the value or array of values at a given path contains any of the specified values- path
The indexed field to be searched.
- value
The string value to search for.
- values
More fields to be searched.
- returns
The requested
SearchOperator
.
- See also
- def in(path: FieldSearchPath, value: UUID, values: UUID*): InSearchOperator
Returns a
SearchOperator
that searches for documents where the value or array of values at a given path contains any of the specified valuesReturns a
SearchOperator
that searches for documents where the value or array of values at a given path contains any of the specified values- path
The indexed field to be searched.
- value
The uuid value to search for.
- values
More fields to be searched.
- returns
The requested
SearchOperator
.
- See also
- def in(path: FieldSearchPath, value: Instant, values: Instant*): InSearchOperator
Returns a
SearchOperator
that searches for documents where the value or array of values at a given path contains any of the specified valuesReturns a
SearchOperator
that searches for documents where the value or array of values at a given path contains any of the specified values- path
The indexed field to be searched.
- value
The instant date value to search for.
- values
More fields to be searched.
- returns
The requested
SearchOperator
.
- See also
- def in(path: FieldSearchPath, value: Number, values: Number*): InSearchOperator
Returns a
SearchOperator
that searches for documents where the value or array of values at a given path contains any of the specified valuesReturns a
SearchOperator
that searches for documents where the value or array of values at a given path contains any of the specified values- path
The indexed field to be searched.
- value
The number value to search for.
- values
More fields to be searched.
- returns
The requested
SearchOperator
.
- See also
- def in(path: FieldSearchPath, value: ObjectId, values: ObjectId*): InSearchOperator
Returns a
SearchOperator
that searches for documents where the value or array of values at a given path contains any of the specified valuesReturns a
SearchOperator
that searches for documents where the value or array of values at a given path contains any of the specified values- path
The indexed field to be searched.
- value
The objectId value to search for.
- values
More fields to be searched.
- returns
The requested
SearchOperator
.
- See also
- def in(path: FieldSearchPath, value: Boolean, values: Boolean*): InSearchOperator
Returns a
SearchOperator
that searches for documents where the value or array of values at a given path contains any of the specified valuesReturns a
SearchOperator
that searches for documents where the value or array of values at a given path contains any of the specified values- path
The indexed field to be searched.
- value
The boolean value to search for.
- values
More fields to be searched.
- returns
The requested
SearchOperator
.
- See also
- def moreLikeThis(likes: Iterable[BsonDocument]): MoreLikeThisSearchOperator
Returns a
SearchOperator
that returns documents similar to input documents.Returns a
SearchOperator
that returns documents similar to input documents.- likes
The BSON documents that are used to extract representative terms to query for.
- returns
The requested
SearchOperator
.
- See also
- def moreLikeThis(like: BsonDocument): MoreLikeThisSearchOperator
Returns a
SearchOperator
that returns documents similar to input document.Returns a
SearchOperator
that returns documents similar to input document.- like
The BSON document that is used to extract representative terms to query for.
- returns
The requested
SearchOperator
.
- See also
- def near(origin: Point, pivot: Number, paths: Iterable[_ <: FieldSearchPath]): GeoNearSearchOperator
Returns a
SearchOperator
that allows finding results that are near the specifiedorigin
.Returns a
SearchOperator
that allows finding results that are near the specifiedorigin
.- origin
The origin from which the proximity of the results is measured. The relevance score is 1 if the values of the fields are
origin
.- pivot
The positive distance in meters from the
origin
at which the relevance score drops in half.- paths
The non-empty fields to be searched.
- returns
The requested
SearchOperator
.
- See also
- def near(origin: Point, pivot: Number, path: FieldSearchPath, paths: FieldSearchPath*): GeoNearSearchOperator
Returns a
SearchOperator
that allows finding results that are near the specifiedorigin
.Returns a
SearchOperator
that allows finding results that are near the specifiedorigin
.- origin
The origin from which the proximity of the results is measured. The relevance score is 1 if the values of the fields are
origin
.- pivot
The positive distance in meters from the
origin
at which the relevance score drops in half.- path
The field to be searched.
- paths
More fields to be searched.
- returns
The requested
SearchOperator
.
- See also
- def near(origin: Instant, pivot: Duration, paths: Iterable[_ <: FieldSearchPath]): DateNearSearchOperator
Returns a
SearchOperator
that allows finding results that are near the specifiedorigin
.Returns a
SearchOperator
that allows finding results that are near the specifiedorigin
.- origin
The origin from which the proximity of the results is measured. The relevance score is 1 if the values of the fields are
origin
.- pivot
The positive distance from the
origin
at which the relevance score drops in half. Data is extracted viaDuration.toMillis
.- paths
The non-empty fields to be searched. It is converted to
long
viaDuration.toMillis
.- returns
The requested
SearchOperator
.
- See also
org.bson.codecs.jsr310.InstantCodec
- def near(origin: Instant, pivot: Duration, path: FieldSearchPath, paths: FieldSearchPath*): DateNearSearchOperator
Returns a
SearchOperator
that allows finding results that are near the specifiedorigin
.Returns a
SearchOperator
that allows finding results that are near the specifiedorigin
.- origin
The origin from which the proximity of the results is measured. The relevance score is 1 if the values of the fields are
origin
.- pivot
The positive distance from the
origin
at which the relevance score drops in half. Data is extracted viaDuration.toMillis
.- path
The field to be searched.
- paths
More fields to be searched.
- returns
The requested
SearchOperator
.
- See also
org.bson.codecs.jsr310.InstantCodec
- def near(origin: Number, pivot: Number, paths: Iterable[_ <: FieldSearchPath]): NumberNearSearchOperator
Returns a
SearchOperator
that allows finding results that are near the specifiedorigin
.Returns a
SearchOperator
that allows finding results that are near the specifiedorigin
.- origin
The origin from which the proximity of the results is measured. The relevance score is 1 if the values of the fields are
origin
.- pivot
The positive distance from the
origin
at which the relevance score drops in half.- paths
The non-empty fields to be searched.
- returns
The requested
SearchOperator
.
- See also
- def near(origin: Number, pivot: Number, path: FieldSearchPath, paths: FieldSearchPath*): NumberNearSearchOperator
Returns a
SearchOperator
that allows finding results that are near the specifiedorigin
.Returns a
SearchOperator
that allows finding results that are near the specifiedorigin
.- origin
The origin from which the proximity of the results is measured. The relevance score is 1 if the values of the fields are
origin
.- pivot
The positive distance from the
origin
at which the relevance score drops in half.- path
The field to be searched.
- paths
More fields to be searched.
- returns
The requested
SearchOperator
.
- See also
- def numberRange(paths: Iterable[_ <: FieldSearchPath]): NumberRangeSearchOperatorBase
Returns a base for a
SearchOperator
that tests if the BSON32-bit integer
/64-bit integer
/Double
values of the specified fields are within an interval.Returns a base for a
SearchOperator
that tests if the BSON32-bit integer
/64-bit integer
/Double
values of the specified fields are within an interval.- paths
The non-empty fields to be searched.
- returns
A base for a
NumberRangeSearchOperator
.
- See also
- def numberRange(path: FieldSearchPath, paths: FieldSearchPath*): NumberRangeSearchOperatorBase
Returns a base for a
SearchOperator
that tests if the BSON32-bit integer
/64-bit integer
/Double
values of the specified fields are within an interval.Returns a base for a
SearchOperator
that tests if the BSON32-bit integer
/64-bit integer
/Double
values of the specified fields are within an interval.- path
The field to be searched.
- paths
More fields to be searched.
- returns
A base for a
NumberRangeSearchOperator
.
- See also
- def of(operator: Bson): SearchOperator
Creates a
SearchOperator
from aBson
in situations when there is no builder method that better satisfies your needs.Creates a
SearchOperator
from aBson
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 equivalentSearchOperator
s, though they may not be equal.val operator1: SearchOperator = SearchOperator.exists( SearchPath.fieldPath("fieldName")) val operator2: SearchOperator = SearchOperator.of(Document("exists" -> Document("path" -> SearchPath.fieldPath("fieldName").toValue)))
- operator
A
Bson
representing the requiredSearchOperator
.- returns
The requested
SearchOperator
.
- def phrase(paths: Iterable[_ <: SearchPath], queries: Iterable[String]): PhraseSearchOperator
Returns a
SearchOperator
that performs a search for documents containing an ordered sequence of terms.Returns a
SearchOperator
that performs a search for documents containing an ordered sequence of terms.- paths
The non-empty fields to be searched.
- queries
The non-empty strings to search for.
- returns
The requested
SearchOperator
.
- See also
- def phrase(path: SearchPath, query: String): PhraseSearchOperator
Returns a
SearchOperator
that performs a search for documents containing an ordered sequence of terms.Returns a
SearchOperator
that performs a search for documents containing an ordered sequence of terms.- path
The field to be searched.
- query
The string to search for.
- returns
The requested
SearchOperator
.
- See also
- def queryString(defaultPath: FieldSearchPath, query: String): QueryStringSearchOperator
Returns a
SearchOperator
that supports querying a combination of indexed fields and values.Returns a
SearchOperator
that supports querying a combination of indexed fields and values.- defaultPath
The field to be searched by default.
- query
One or more indexed fields and values to search.
- returns
The requested
SearchOperator
.
- See also
- def regex(paths: Iterable[_ <: SearchPath], queries: Iterable[String]): RegexSearchOperator
Returns a
SearchOperator
that performs a search using a regular expression.Returns a
SearchOperator
that performs a search using a regular expression.- paths
The non-empty fields to be searched.
- queries
The non-empty strings to search for.
- returns
The requested
SearchOperator
.
- See also
- def regex(path: SearchPath, query: String): RegexSearchOperator
Returns a
SearchOperator
that performs a search using a regular expression.Returns a
SearchOperator
that performs a search using a regular expression.- path
The field to be searched.
- query
The string to search for.
- returns
The requested
SearchOperator
.
- See also
- def text(paths: Iterable[_ <: SearchPath], queries: Iterable[String]): TextSearchOperator
Returns a
SearchOperator
that performs a full-text search.Returns a
SearchOperator
that performs a full-text search.- paths
The non-empty fields to be searched.
- queries
The non-empty strings to search for.
- returns
The requested
SearchOperator
.
- See also
- def text(path: SearchPath, query: String): TextSearchOperator
Returns a
SearchOperator
that performs a full-text search.Returns a
SearchOperator
that performs a full-text search.- path
The field to be searched.
- query
The string to search for.
- returns
The requested
SearchOperator
.
- See also
- def wildcard(queries: Iterable[String], paths: Iterable[_ <: SearchPath]): WildcardSearchOperator
Returns a
SearchOperator
that enables queries which use special characters in the search string that can match any character.Returns a
SearchOperator
that enables queries which use special characters in the search string that can match any character.- queries
The non-empty strings to search for.
- paths
The non-empty indexed fields to be searched.
- returns
The requested
SearchOperator
.
- See also
- def wildcard(query: String, path: SearchPath): WildcardSearchOperator
Returns a
SearchOperator
that enables queries which use special characters in the search string that can match any character.Returns a
SearchOperator
that enables queries which use special characters in the search string that can match any character.- query
The string to search for.
- path
The indexed field to be searched.
- returns
The requested
SearchOperator
.
- See also
This is the documentation for the MongoDB Scala driver.
Driver structure
The mongodb scala driver.
To get started you need a MongoClient instance, either from a connection string or via a org.mongodb.scala.MongoClientSettings.
Notable packages include: