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
Static MethodsModifier and TypeMethodDescriptionstatic BsoncombineToBson(Iterable<? extends SearchFacet> facets) CombinesSearchFacets into aBson.static DateSearchFacetdateFacet(String name, FieldSearchPath path, Iterable<Instant> boundaries) Returns aSearchFacetthat allows determining the frequency of BSONDatevalues in the search results by breaking the results into separate ranges.static NumberSearchFacetnumberFacet(String name, FieldSearchPath path, Iterable<? extends Number> boundaries) Returns aSearchFacetthat allows determining the frequency of BSON32-bit integer/64-bit integer/Doublevalues in the search results by breaking the results into separate ranges.static SearchFacetCreates aSearchFacetfrom aBsonin situations when there is no builder method that better satisfies your needs.static StringSearchFacetstringFacet(String name, FieldSearchPath path) Returns aSearchFacetthat allows narrowing down search results based on the most frequent BSONStringvalues of the specified field.Methods inherited from interface org.bson.conversions.Bson
toBsonDocument, toBsonDocument
-
Method Details
-
stringFacet
Returns aSearchFacetthat allows narrowing down search results based on the most frequent BSONStringvalues 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 aSearchFacetthat allows determining the frequency of BSON32-bit integer/64-bit integer/Doublevalues 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 aSearchFacetthat allows determining the frequency of BSONDatevalues 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 aSearchFacetfrom 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 equivalentSearchFacets, 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- ABsonrepresenting the requiredSearchFacet.- Returns:
- The requested
SearchFacet.
-
combineToBson
- Parameters:
facets- The non-empty facet definitions to combine.- Returns:
- A
Bsonrepresenting combinedfacets.
-