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
Static MethodsModifier and TypeMethodDescriptionstatic ValueBoostSearchScoreboost(float value) Returns aSearchScorethat instructs to multiply the score by the specifiedvalue.static PathBoostSearchScoreboost(FieldSearchPath path) Returns aSearchScorethat instructs to multiply the score by the value of the specified field.static ConstantSearchScoreconstant(float value) Returns aSearchScorethat instructs to replace the score with the specifiedvalue.static FunctionSearchScorefunction(SearchScoreExpression expression) Returns aSearchScorethat instructs to compute the score using the specifiedexpression.static SearchScoreCreates aSearchScorefrom aBsonin 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 aSearchScorethat 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 aSearchScorethat 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 aSearchScorethat 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 aSearchScorethat 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 aSearchScorefrom aBsonin 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 equivalentSearchScores, 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- ABsonrepresenting the requiredSearchScore.- Returns:
- The requested
SearchScore.
-