We are using native search query builder as follows:
String[] includeFields = new String[]{"idDl", "clientName"};
String[] excludeFields = new String[]{"Address"};
Query searchQuery = new NativeSearchQueryBuilder()
.withQuery(matchAllQuery())
.withSourceFilter(new FetchSourceFilter(includeFields, excludeFields))
.build();
return elasticsearchRestTemplate.queryForObject((StringQuery) searchQuery, User.class);
I am able to get all the response data but first response object is all null fields, i want to exclude all null fields object in the final response. We are using we're using spring-data-elasticsearch 3.2.6.RELEASE and here is the sample response:
[{
"idDl": null,
"clientName": null,
"Address": null
},
{
"idDl": 19810008,
"clientName": "ABC",
"Address": "NYC"
}]