0

I am using redis-om-spring:1.0.4 with spring boot 3.4.10 for getting @Document support.

I have some class like

 @Setter
 @Getter
 class Vehicle {
 @Id
 private String id;
 @Searchable
 private String model;
 @Reference
 @Indexed
 private Owner owner;
 }
 
 @Setter
 @Getter
 class Owner{
 @Id
 private String id;
 @Searchable
 private String name;
 }

There are generated metamodel classes: Vehicle$ and Owner$.

I tried to filter document by using Entity Stream Search:

@Service
class SomeService{
 @Autowired
 private EntitySearch entitysearch;
 public List<Vehicle> findBy(String model, String name) {
 try (var search = entitysearch.of(Vehicle.class)) {
 if (!ObjectUtils.isEmpty(model)) {
 search.filter(Vehicle$.MODEL.eq(model));
 }
 if (!ObjectUtils.isEmpty(name)) {
 search.filter(Vehicle$.OWNER.NAME.eq(name)); // Here the problem
 }
 
 return stream.collection(Collectors.toList());
 }
 }
}

The problem that Vehicle$.OWNER is ReferenceField type and has only eq(Owner owner) method. And code like this Employee$.DEPARTMENT.eq(somePredicate) from the Redis OM Spring doesn't compile

Structure of ReferenceField class

I've seen that in old version 0.8.0 we can access to field like this Vehicle$.OWNER_NAME.eq(). But in 1.0.4 it doesn't generate some value

I don't want create fake Owner instances. What if we has collection of values and want to find any document that contains in the set, Vehicle$.OWNER.NAME.in(someCollection)

President Jam
1,2181 gold badge6 silver badges22 bronze badges
asked yesterday
1

0

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.