Package com.mongodb.client.model.search
Interface SearchFacet
- All Superinterfaces:
Bson
- All Known Subinterfaces:
DateSearchFacet
,NumberSearchFacet
,StringSearchFacet
A facet definition for
FacetSearchCollector
.- Since:
- 4.7
- MongoDB Atlas documentation
- Facet definition
-
Field Summary
Fields inherited from interface org.bson.conversions.Bson
DEFAULT_CODEC_REGISTRY
-
Method Summary
Modifier and TypeMethodDescriptionstatic Bson
combineToBson
(Iterable<? extends SearchFacet> facets) CombinesSearchFacet
s into aBson
.static DateSearchFacet
dateFacet
(String name, FieldSearchPath path, Iterable<Instant> boundaries) Returns aSearchFacet
that allows determining the frequency of BSONDate
values in the search results by breaking the results into separate ranges.static NumberSearchFacet
numberFacet
(String name, FieldSearchPath path, Iterable<? extends Number> boundaries) Returns aSearchFacet
that allows determining the frequency of BSON32-bit integer
/64-bit integer
/Double
values in the search results by breaking the results into separate ranges.static SearchFacet
Creates aSearchFacet
from aBson
in situations when there is no builder method that better satisfies your needs.static StringSearchFacet
stringFacet
(String name, FieldSearchPath path) Returns aSearchFacet
that allows narrowing down search results based on the most frequent BSONString
values of the specified field.Methods inherited from interface org.bson.conversions.Bson
toBsonDocument, toBsonDocument
-
Method Details
-
stringFacet
Returns aSearchFacet
that allows narrowing down search results based on the most frequent BSONString
values of the specified field.- Parameters:
name
- The facet name.path
- The field to facet on.- Returns:
- The requested
SearchFacet
. - MongoDB Atlas documentation
- String facet definition
-
numberFacet
static NumberSearchFacet numberFacet(String name, FieldSearchPath path, Iterable<? extends Number> boundaries) Returns aSearchFacet
that allows determining the frequency of BSON32-bit integer
/64-bit integer
/Double
values in the search results by breaking the results into separate ranges.- Parameters:
name
- The facet name.path
- The path to facet on.boundaries
- Bucket boundaries in ascending order. Must contain at least two boundaries.- Returns:
- The requested
SearchFacet
. - MongoDB Atlas documentation
- Numeric facet definition
-
dateFacet
Returns aSearchFacet
that allows determining the frequency of BSONDate
values in the search results by breaking the results into separate ranges.- Parameters:
name
- The facet name.path
- The path to facet on.boundaries
- Bucket boundaries in ascending order. Must contain at least two boundaries.- Returns:
- The requested
SearchFacet
. - See Also:
- MongoDB Atlas documentation
- Date facet definition
-
of
Creates aSearchFacet
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 equivalentSearchFacet
s, though they may not be equal.SearchFacet facet1 = SearchFacet.stringFacet("facetName", SearchPath.fieldPath("fieldName")); SearchFacet facet2 = SearchFacet.of(new Document("facetName", new Document("type", "string") .append("path", SearchPath.fieldPath("fieldName").toValue())));
- Parameters:
facet
- ABson
representing the requiredSearchFacet
.- Returns:
- The requested
SearchFacet
.
-
combineToBson
- Parameters:
facets
- The non-empty facet definitions to combine.- Returns:
- A
Bson
representing combinedfacets
.
-