Unable to create FieldDefinition for nullable field using Atlas Search C# driver

Using the C# Linq syntax for Atlas Search, I’m unable to create a FieldDefinition for a nullable field. I’m using the latest version of the .NET driver, 2.23.1.

For example, this does not work if MyNullableField refers to a nullable type, like a nullable boolean, DateTime or ObjectId. (Non-nullable fields work fine.)

Builders<MyModel>.Search.Equals(model => model.MyNullableField, id)

The compiler error is “The type {type} must be a non-nullable value type in order to use it as parameter ‘TField’”

But this syntax works:

Builders<MyModel>.Search.Equals("MyNullableField", id)

Note that this problem affects not only the “Equals” operator, but all operations – Range, etc.

I’d prefer to use the strongly typed version rather than relying on name strings. Are there any other workarounds for this? Should I file a bug report?