Spring Data Elasticsearch - Field Projections? - spring-boot

As I saw Projections in Spring Data JPA documentation here
but this doesn't seems to exist in Spring Data Elasticsearch.
Is there any best practices for source filtering or projections in Spring Data Elasticsearch?
I already tried creating my custom Repository and put sourceFilter with QueryBuilder. It works but I don't really want to create custom repository.

Related

What is the best way to maintain queries in Spring boot application?

In My Application, Using the below technologies
Spring boot 2.7.x
Cassandra
spring batch 5. x
java 11
As part of this, I need to extract data from the Cassandra database and need to write out the file
so here I need to use queries to fetch data so
just want to know what is the best way to maintain all queries at one place so any query changes come in the future, I shouldn't build the app rather just need to modify the query.
Using a repository class is necessary. If you are using JPA i recommend using a repository for each Entity class. With JDBC it is possible to create a single repository which contains all the queries. To access the query methodes i would use a service class. In this way your code is structured well and maintainable for future changes.

AuditAware with Kotlin Exposed

I have a project using Kotlin in Spring Boot. The tables have the standard audit fields 'createdBy', 'createdDt'. Is there a way to handle setting these fields in some way that doesn't involve passing these fields around? Ideally I'd like to intercept every transaction before commit and just set the fields on the entities.
Using JPA and Hibernate, an AuditAware bean could be used to pass the current Principal along with using annotations. Is there a similar integration available or easily implemented? I've looked at the EntityHooks class and don't see an easy way to change data.

How to set multiple data sources in Spring Data R2DBC

I am using spring data r2dbc in my new project and need to connect multiple data sources like A data source and B data source.
Is there a way to connect multiple data sources using r2dbc?
Could I get an example or a document if there is a way?
My stacks are below:
Spring Boot 2.3.0.M4
Spring WebFlux
Spring Data R2DBC
If you want to use multiple datasources in a single application, check my multi r2dbc connection factories example.
If you need a multi-tenant like feature check this multi-tenancy-r2dbc example.
I solved this issue using AbstractRoutingConnectionFactory you can check Add support for AbstractRoutingConnectionFactory

Can I use JPARepository with an Elasticsearch datasource?

Can I use an ES data source with JPA Repository? The main reason I ask is that I would like to use the JPA Specification executor for queries.
Thanks.
No. Specificationand JpaSpecification are based on JPA queries which are different than Spring Data Elasticsearch queries.

Text search with Spring Data Redis

I am trying to find documentation around creating and searching a text index on redis using Spring Data. I see #Indexed but dont find #TextIndexed like with Spring data MongoDB.
https://github.com/RedisLabs/JRediSearch
There's no Redis module support in Spring Data Redis and we don't plan to add support for Redis modules.

Resources