Am unable to filters on Date fields with Redis

117 views Asked by At

Am unable to filter on Date fields with Redis-search eg: entityStream.of(Object.class), at the same time, being able to filter other data types but not with Date type

tried with the below patterns but not working

SearchStream search = entityStream.of(Person.class);

search.filter(Person$.DOB.onOrAfter(dob)); //yyyy-MM-dd HH:mm:ss

Model can be seen in attached [1]: https://i.stack.imgur.com/GUmTb.png

1

There are 1 answers

2
BSB On

The issue is that to be able to index the Date, they need to be stored as a numeric value in Redis (to use the search engine NUMERIC schema field). So the two Json annotations:

@JsonDeserialize(using = LocalDateTimeDeserializer.class)
@JsonSerialize(using = LocalDateTimeSerializer.class)

Are preventing the built-in Serializers in Redis OM from storing this as numbers. To prevent that from happening you could remove those and let the Redis OM serializers deal with it.