Getting only selected column in Spring Data Elastic Search Repository

I am using Elasticsearch Respository with my Java High Level Rest Client for connecting with my Elasticsearch.

Now, I have managed to write a complex query which uses nested, should and must keywords to get certain data from elastic search. However, since I am using @Query annotation, I am not able to write _source column in it for getting only selected properties, not all of them.

I have

@Query(//a very big query)

But according to documentation, the syntax is:

public interface BookRepository extends ElasticsearchRepository<Book,String> { @Query("{"bool" : {"must" : {"field" : {"name" : "?0"}}}}") Page<Book> findByName(String name); }

Now, where am I supposed to add "_source" for getting only selected columns.

Another way around is to perform this logic on another java service.

Let me know if there is a solution to this.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.