Class RerankQuery

java.lang.Object
com.mongodb.client.model.RerankQuery
All Implemented Interfaces:
Bson

@Beta(SERVER) public final class RerankQuery extends Object implements Bson
Represents a query for the $rerank aggregation pipeline stage.

The $rerank stage is available only in MongoDB Atlas.

Use rerankQuery(String) for a simple text query, or rerankQuery(Bson) to specify the full query document directly (e.g., for future modalities like imageURL or videoURL).

Since:
5.8
Since server release
8.3
  • Method Details

    • rerankQuery

      public static RerankQuery rerankQuery(String text)
      Creates a rerank query with the specified text.

      This is a convenience for rerankQuery(new Document("text", text)).

      Parameters:
      text - the query text to rerank against.
      Returns:
      a new RerankQuery
    • rerankQuery

      public static RerankQuery rerankQuery(Bson query)
      Creates a rerank query from a full query document.

      Use this overload for future query modalities (e.g., imageURL, videoURL) or to pass additional fields alongside text.

      Parameters:
      query - the query document.
      Returns:
      a new RerankQuery
    • toBsonDocument

      public <TDocument> BsonDocument toBsonDocument(Class<TDocument> documentClass, CodecRegistry codecRegistry)
      Specified by:
      toBsonDocument in interface Bson
    • toString

      public String toString()
      Overrides:
      toString in class Object