Package com.mongodb.client.model.search
Interface SearchHighlight
- All Superinterfaces:
Bson
Highlighting options.
You may use the
$meta: "searchHighlights" expression, e.g., via Projections.metaSearchHighlights(String),
to extract the results of highlighting.- Since:
- 4.7
- MongoDB Atlas documentation
- Highlighting
-
Field Summary
Fields inherited from interface org.bson.conversions.Bson
DEFAULT_CODEC_REGISTRY -
Method Summary
Modifier and TypeMethodDescriptionmaxCharsToExamine(int maxCharsToExamine) Creates a newSearchHighlightwith the maximum number of characters to examine on a document when performing highlighting for a field.maxNumPassages(int maxNumPassages) Creates a newSearchHighlightwith the maximum number of high-scoring passages to return per document in the"highlights"results for each field.static SearchHighlightCreates aSearchHighlightfrom aBsonin situations when there is no builder method that better satisfies your needs.static SearchHighlightpaths(SearchPath path, SearchPath... paths) Returns aSearchHighlightfor the givenpaths.static SearchHighlightpaths(Iterable<? extends SearchPath> paths) Returns aSearchHighlightfor the givenpaths.Methods inherited from interface org.bson.conversions.Bson
toBsonDocument, toBsonDocument
-
Method Details
-
maxCharsToExamine
Creates a newSearchHighlightwith the maximum number of characters to examine on a document when performing highlighting for a field.- Parameters:
maxCharsToExamine- The maximum number of characters to examine.- Returns:
- A new
SearchHighlight.
-
maxNumPassages
Creates a newSearchHighlightwith the maximum number of high-scoring passages to return per document in the"highlights"results for each field.- Parameters:
maxNumPassages- The maximum number of high-scoring passages.- Returns:
- A new
SearchHighlight.
-
paths
Returns aSearchHighlightfor the givenpaths.- Parameters:
path- The field to be searched.paths- More fields to be searched.- Returns:
- The requested
SearchHighlight.
-
paths
Returns aSearchHighlightfor the givenpaths.- Parameters:
paths- The non-empty fields to be searched.- Returns:
- The requested
SearchHighlight.
-
of
Creates aSearchHighlightfrom 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 equivalentSearchHighlights, though they may not be equal.SearchHighlight highlight1 = SearchHighlight.paths( SearchPath.fieldPath("fieldName"), SearchPath.wildcardPath("wildc*rd")); SearchHighlight highlight2 = SearchHighlight.of(new Document("path", Arrays.asList( SearchPath.fieldPath("fieldName").toBsonValue(), SearchPath.wildcardPath("wildc*rd").toBsonValue())));- Parameters:
highlight- ABsonrepresenting the requiredSearchHighlight.- Returns:
- The requested
SearchHighlight.
-