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 newSearchHighlight
with the maximum number of characters to examine on a document when performing highlighting for a field.maxNumPassages
(int maxNumPassages) Creates a newSearchHighlight
with the maximum number of high-scoring passages to return per document in the"highlights"
results for each field.static SearchHighlight
Creates aSearchHighlight
from aBson
in situations when there is no builder method that better satisfies your needs.static SearchHighlight
paths
(SearchPath path, SearchPath... paths) Returns aSearchHighlight
for the givenpaths
.static SearchHighlight
paths
(Iterable<? extends SearchPath> paths) Returns aSearchHighlight
for the givenpaths
.Methods inherited from interface org.bson.conversions.Bson
toBsonDocument, toBsonDocument
-
Method Details
-
maxCharsToExamine
Creates a newSearchHighlight
with 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 newSearchHighlight
with 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 aSearchHighlight
for the givenpaths
.- Parameters:
path
- The field to be searched.paths
- More fields to be searched.- Returns:
- The requested
SearchHighlight
.
-
paths
Returns aSearchHighlight
for the givenpaths
.- Parameters:
paths
- The non-empty fields to be searched.- Returns:
- The requested
SearchHighlight
.
-
of
Creates aSearchHighlight
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 equivalentSearchHighlight
s, 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
- ABson
representing the requiredSearchHighlight
.- Returns:
- The requested
SearchHighlight
.
-