spring-data-elasticsearch icon indicating copy to clipboard operation
spring-data-elasticsearch copied to clipboard

How to set the value of the _source option to false ?

Open pop1213 opened this issue 1 year ago • 1 comments

set _source option like this

GET /_search
{
  "_source": false,
  "query": {
    "match": {
      "user.id": "kimchy"
    }
  }
}

pop1213 avatar Oct 22 '24 13:10 pop1213

Spring Data Elasticsearch does not directly allow setting this to false, but you can use a source filter to either include no fields or exclude all fields from the source on a Spring Data Elasticsearch Query:

var query = Query.findAll();
// use either
query.addSourceFilter(FetchSourceFilter.of(b -> b.withExcludes("*")));
// or
query.addSourceFilter(FetchSourceFilter.of(b -> b.withIncludes("")));

sothawo avatar Oct 22 '24 18:10 sothawo

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

spring-projects-issues avatar Oct 29 '24 19:10 spring-projects-issues