Home > database >  How exclude fields from _source with spring data elasticsearch?
How exclude fields from _source with spring data elasticsearch?

Time:02-27

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?

CodePudding user response:

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.

  • Related