Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How exclude fields from _source with spring data elasticsearch?

The @Query annotation contains no options for this.
I can’t add –

{
  "_source": {
    "includes": [
      "id",
      "name",
      "address"
    ]
  },
  "query": {
    ...
  }
}

Projections don’t work in ES repositories.

The only way is to make your own repository (NativeSearchQuery and ect.) or DTO?
Why can’t these things be made easier?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

All the query implementations from Spring Data Elasticsearch have the possibility to set a source filter.

The @Query annotation can only contain the query part as you wrote, there is already a ticket to make this more flexible.

Why can’t these things be made easier?

Well, Spring Data Elasticsearch is a community driven project, so if you want to contribute to it, you are welcome.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading