Skip to content

Add entity relationship mapping support #10

@xmlking

Description

@xmlking

This issue is to track some of the features still in development:

  1. RedisHash: @Reference deserialization is not working e.g., User has Role. Serialization works but not deserialization. This was working in the original Spring Data Redis (SDR). Indexing works as expected.

    Redis Hash use case:

    @RedisHash
    data class Role(
        @Id
        var id: String?,
        @Indexed
        var roleName: String
    )
    
    @RedisHash
    data class User(
        @Id
        val id: String?,
        @Indexed
        val firstName: String,
        @Indexed
        val middleName: String?,
        @Searchable
        val lastName: String,
        @Indexed
        @Bloom(name = "bf_user_email", capacity = 100000, errorRate = 0.001)
        var email: String,
        @Reference
        val role: Role
    )
  2. RedisJSON: Search index creation not working for complex nested entities . e.g., Person has Addresses and Name.
    Current state: Person get persisted along with all nested entities in one JSON record, but index is only created on top-level entity annotated with @Document

    RedisJSON use case:

    @Document("person")
    data class Person(
        @Id val id: String? = null,
        @Indexed
        val name: Name,
        @Indexed
        val addresses: Set<Address> = setOf(),
        val gender: Gender?,
        val dob: Date?,
        @Indexed
        @Bloom(name = "bf_person_email", capacity = 100000, errorRate = 0.001)
        var email: String,
    
        val phone: String? = null,
        val avatar: String = "https://www.gravatar.com/avatarr"
    ) {
        fun addAddress(address: Address) {
            (this.addresses as HashSet).add(address)
        }
    }
    
    data class Name(
        @Searchable
        @field:NotNull
        @field:Pattern(regexp = "[A-Za-z0-9_]+", message = "FirstName must contain only letters and numbers")
        @field:Size(min = 4, max = 26, message = "FirstName must be between {min} and {max} characters")
        val first: String?,
    
        @Searchable
        @field:NotBlank
        @field:Pattern(regexp = "[A-Za-z0-9_]+", message = "LastName must contain only letters and numbers")
        val last: String?,
        val title: String? = null
    )
    
    
    data class Address(
        @Id val id: String? = null,
        val suite: String? = null,
        @Searchable
        val street: String,
        @Indexed
        val city: String,
        @Indexed
        val state: String,
        val code: String,
        @Indexed
        val country: String,
        @Indexed
        @Serializable(with = PointSerializer::class) val location: Point? = null
    )

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions