Queryable Encryption - Encrypting data with Random algorithm

I am queryable encryption to automatically encrypt certain fields using random algorithm. Encryption rules are specified using Json schema. I can save the collection and the sensitive fields are automatically encrypted, but getting below error when I search by the sensitive field

nested exception is org.springframework.data.mongodb.UncategorizedMongoDbException: Exception in encryption library: csfle "analyze_query" failed: Cannot query on fields encrypted with the randomized encryption algorithm [Error 2, code 51158]; nested exception is com.mongodb.MongoClientException: Exception in encryption library: csfle "analyze_query" failed: Cannot query on fields encrypted with the randomized encryption algorithm [Error 2, code 51158]] with root cause

com.mongodb.crypt.capi.MongoCryptException: csfle "analyze_query" failed: Cannot query on fields encrypted with the randomized encryption algorithm [Error 2, code 51158]
	at com.mongodb.crypt.capi.MongoCryptContextImpl.throwExceptionFromStatus(MongoCryptContextImpl.java:156)

Does this mean searching by encrypted field is not possible when using random algorithm ?
I can query if deterministic algorithm is used.

Vinod

You should add the queries field for the field you want to query against during the creation of the encrypted collection.
For ex:

  const encryptedFieldsMap = {
    encryptedFields: {
      fields: [
        {
          path: "email",
          bsonType: "string",
          queries: { queryType: "equality" },
        }
   }
}

In the above code, we’re telling mongodb that the encrypted field email would be queried by equality searches in the future.
If however you donot provide the queries field during the creation of encrypted collection, the error you mentioned could occur.