Interface SearchCount

All Superinterfaces:
org.bson.conversions.Bson
All Known Subinterfaces:
LowerBoundSearchCount, TotalSearchCount

@Sealed @Beta({CLIENT,SERVER}) public interface SearchCount extends org.bson.conversions.Bson
Counting options. You may use the $$SEARCH_META variable, e.g., via Projections.computedSearchMeta(String), to extract the results of counting.
Since:
4.7
MongoDB Atlas documentation
Counting
  • Field Summary

    Fields inherited from interface org.bson.conversions.Bson

    DEFAULT_CODEC_REGISTRY
  • Method Summary

    Static Methods
    Modifier and Type
    Method
    Description
    Returns a SearchCount that instructs to count documents exactly only up to a threshold.
    of(org.bson.conversions.Bson count)
    Creates a SearchCount from a Bson in situations when there is no builder method that better satisfies your needs.
    Returns a SearchCount that instructs to count documents exactly.

    Methods inherited from interface org.bson.conversions.Bson

    toBsonDocument, toBsonDocument
  • Method Details

    • total

      static TotalSearchCount total()
      Returns a SearchCount that instructs to count documents exactly.
      Returns:
      The requested SearchCount.
    • lowerBound

      static LowerBoundSearchCount lowerBound()
      Returns a SearchCount that instructs to count documents exactly only up to a threshold.
      Returns:
      The requested SearchCount.
    • of

      static SearchCount of(org.bson.conversions.Bson count)
      Creates a SearchCount from a Bson 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 equivalent SearchCounts, though they may not be equal.

      
        SearchCount count1 = SearchCount.lowerBound();
        SearchCount count2 = SearchCount.of(new Document("type", "lowerBound"));
       
      Parameters:
      count - A Bson representing the required SearchCount.
      Returns:
      The requested SearchCount.