Interface SearchCount

All Superinterfaces:
Bson
All Known Subinterfaces:
LowerBoundSearchCount, TotalSearchCount

@Evolving @Beta({CLIENT,SERVER}) public interface SearchCount extends 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
  • 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(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.