Package com.mongodb.client.model.search
Interface SearchScore
- All Superinterfaces:
Bson
- All Known Subinterfaces:
ConstantSearchScore
,FunctionSearchScore
,PathBoostSearchScore
,ValueBoostSearchScore
A modifier of the relevance score.
You may use the
$meta: "searchScore"
expression, e.g., via Projections.metaSearchScore(String)
,
to extract the relevance score assigned to each found document.- Since:
- 4.7
- MongoDB Atlas documentation
- Scoring
-
Field Summary
Fields inherited from interface org.bson.conversions.Bson
DEFAULT_CODEC_REGISTRY
-
Method Summary
Modifier and TypeMethodDescriptionstatic ValueBoostSearchScore
boost
(float value) Returns aSearchScore
that instructs to multiply the score by the specifiedvalue
.static PathBoostSearchScore
boost
(FieldSearchPath path) Returns aSearchScore
that instructs to multiply the score by the value of the specified field.static ConstantSearchScore
constant
(float value) Returns aSearchScore
that instructs to replace the score with the specifiedvalue
.static FunctionSearchScore
function
(SearchScoreExpression expression) Returns aSearchScore
that instructs to compute the score using the specifiedexpression
.static SearchScore
Creates aSearchScore
from aBson
in situations when there is no builder method that better satisfies your needs.Methods inherited from interface org.bson.conversions.Bson
toBsonDocument, toBsonDocument
-
Method Details
-
boost
Returns aSearchScore
that instructs to multiply the score by the specifiedvalue
.- Parameters:
value
- The value to multiply the score by.- Returns:
- The requested
SearchScore
. - MongoDB Atlas documentation
- boost score modifier
-
boost
Returns aSearchScore
that instructs to multiply the score by the value of the specified field.- Parameters:
path
- The numeric field whose value to multiply the score by.- Returns:
- The requested
SearchScore
. - See Also:
- MongoDB Atlas documentation
- boost score modifier
-
constant
Returns aSearchScore
that instructs to replace the score with the specifiedvalue
.- Parameters:
value
- The value to replace the score with.- Returns:
- The requested
SearchScore
. - See Also:
- MongoDB Atlas documentation
- constant score modifier
-
function
Returns aSearchScore
that instructs to compute the score using the specifiedexpression
.- Parameters:
expression
- The expression to use when calculating the score.- Returns:
- The requested
SearchScore
. - MongoDB Atlas documentation
- function score modifier
-
of
Creates aSearchScore
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 equivalentSearchScore
s, though they may not be equal.SearchScore score1 = SearchScore.boost( SearchPath.fieldPath("fieldName")); SearchScore score2 = SearchScore.of(new Document("boost", new Document("path", SearchPath.fieldPath("fieldName").toValue())));
- Parameters:
score
- ABson
representing the requiredSearchScore
.- Returns:
- The requested
SearchScore
.
-