Can somebody verify whether it is possible to do the following using Spring Data Elasticsearch and ElasticsearchRepository?
Here is an example of the object being stored:
public class TopLevel {
@Id
private String id;
private SecondLevel secondLevel;
}
public class SecondLevel {
private UUID id;
private FirstThirdLevel firstThirdLevel;
private SecondThirdLevel secondThirdLevel;
}
public class FirstThirdLevel {
private UUID id;
private String name;
}
public class SecondThirdLevel {
private UUID id;
private Integer num;
}
I have a repository such as:
@Repository
public interface TopLevelRepository extends ElasticsearchRepository<TopLevel, String> {
Page<TopLevel> findAll(Pageable pageable);
}
What I want to do is be able to query using any criteria but only return FirstThirdLevel objects? Is this possible using the above repository definition? Can I create an additional Repository that extends ElasticsearchRepository(FirstThirdLevel, String)?
I know I can stream the TopLevel objects and pull out the subobjects but then I would need to recreate a new Page object to return. I would prefer not to do that unless it is the only possible way.