Filter based on Integer Comparison in Spring data redis

和自甴很熟 提交于 2020-12-15 05:24:05

问题


I am using spring-data-redis to communicate with database.

I have entity class like below

@RedisHash(value = "employee")
public class Employee
{
    @Id
    private long id;
    @Indexed
    private String name;
    @Indexed
    private int age;
    private Address address;

    ...... ...... ......

}

I want to filter the employees based on age group. For example, age lesser than 35 (age<35). How to achieve this in below repository?

@Repository
public interface EmployeeRepo extends CrudRepository<Employee, Long>
{
    public Employee findByName(String name);
}

I dont prefer to load complete data from table and do search using any loop/stream.


回答1:


I don't think it does. I tried to implement what you tried to do using

@Index
long lastUpdatedOn;

when I checked the redis it gives a key entity:lastUpdatedOn:160.... and I tried searching for it using ZRANGE which gives no results.



来源:https://stackoverflow.com/questions/63050222/filter-based-on-integer-comparison-in-spring-data-redis

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!