redis / redis-om-spring

Spring Data Redis extensions for better search, documents models, and more
MIT License
579 stars 91 forks source link

Query problem with UUID #480

Open gusosasi opened 5 days ago

gusosasi commented 5 days ago

I have tested several scenarios and my query does not escape a UUID. This is the command which gets executed

"FT.SEARCH" "org.example.redistest.HiveIdx" "@drones_content:34aebb69-17d2-4405-ac62-dffbeea0cfa5" "LIMIT" "0" "10000"

Code


## Hive
import com.redis.om.spring.annotations.Document;
import com.redis.om.spring.annotations.Indexed;
import org.springframework.data.annotation.Id;

import java.util.Set;
import java.util.UUID;

@Document
public class Hive {

    @Id
    private UUID id;

    @Indexed
    private Set<Drone> drones;

    public Hive() {
    }

    public Hive(UUID id, Set<Drone> drones) {
        this.id = id;
        this.drones = drones;
    }

    public UUID getId() {
        return id;
    }

    public void setId(UUID id) {
        this.id = id;
    }

    public Set<Drone> getDrones() {
        return drones;
    }

    public void setDrones(Set<Drone> drones) {
        this.drones = drones;
    }
}

## Drone
import com.redis.om.spring.annotations.TagIndexed;

import java.util.UUID;

public class Drone {

    @TagIndexed
    private UUID content;

    public Drone() {
    }

    public Drone(UUID content) {
        this.content = content;
    }

    public UUID getContent() {
        return content;
    }

    public void setContent(UUID content) {
        this.content = content;
    }
}

## Repo
import com.redis.om.spring.repository.RedisDocumentRepository;
import org.springframework.stereotype.Repository;

import java.util.UUID;

@Repository
public interface HiveRepository extends RedisDocumentRepository<Hive, String> {

    Iterable<Hive> findByDrones_Content(UUID drones_content);

}
gusosasi commented 5 days ago

Okay after extensive analysis I noticed through another project that this error occurs more often if you have a HashSet in which there are Interfaces.