Skip to content

Support for Non-Queryable Encrypted Fields in CollectionOptions #4988

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ricardohsmello opened this issue May 30, 2025 · 0 comments
Closed
Assignees
Labels
type: enhancement A general enhancement

Comments

@ricardohsmello
Copy link

ricardohsmello commented May 30, 2025

Hi team,

While testing out the CollectionOptions.encryptedCollection feature in Spring Data MongoDB version 4.5.0 with Queryable Encryption, I noticed that currently, it seems I can only encrypt fields that are also marked as queryable. However, in some use cases, I’d like to have fields that are encrypted but not queryable.

For example, I’d like to do something like this:

CollectionOptions collectionOptions = CollectionOptions.encryptedCollection(options -> options
    .encrypted(encrypted(string("name")).keyId(dkName.asUuid()))  // encrypted but not queryable
    .queryable(encrypted(int32("age")).algorithm("Range").keyId(dkAge.asUuid()), range().contention(0).min(0).max(130))  // encrypted and queryable
);

This would allow me to encrypt the "name" field without making it queryable, while still taking advantage of range queries on "age". As of now, the API doesn’t seem to support this scenario.

Let me know if you need anything.

Thanks in advance.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label May 30, 2025
@mp911de mp911de added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels Jun 2, 2025
@mp911de mp911de changed the title Support for Non-Queryable Encrypted Fields in CollectionOptions Support for Non-Queryable Encrypted Fields in CollectionOptions Jun 4, 2025
@mp911de mp911de added this to the 4.5.1 (2025.0.1) milestone Jun 4, 2025
@mp911de mp911de closed this as completed in 194746a Jun 4, 2025
mp911de added a commit that referenced this issue Jun 4, 2025
Fix Javadoc, make QueryCharacteristics a Streamable for easier usage during mapping, reformat code for reduced nesting levels.

See #4988
Original pull request: #4992
mp911de pushed a commit that referenced this issue Jun 4, 2025
mp911de added a commit that referenced this issue Jun 4, 2025
Fix Javadoc, make QueryCharacteristics a Streamable for easier usage during mapping, reformat code for reduced nesting levels.

See #4988
Original pull request: #4992
mp911de added a commit that referenced this issue Jun 5, 2025
Fix test.

See #4988
Original pull request: #4992

# Conflicts:
#	spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/CollectionOptions.java
#	spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/schema/QueryCharacteristics.java
mp911de added a commit that referenced this issue Jun 5, 2025
Fix test.

See #4988
Original pull request: #4992

# Conflicts:
#	spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/CollectionOptions.java
#	spring-data-mongodb/src/main/java/org/springframework/data/mongodb/core/schema/QueryCharacteristics.java
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
4 participants