问题
We are using we're using spring-data-elasticsearch 3.2.6.RELEASE and here is our repository :
@Repository
public interface IRepository extends ElasticsearchRepository<User, Integer> {
List<User> findAll();
}
and here is the sample response:
[{
"idDl": null,
"clientName": null,
"Address": null
},
{
"idDl": 19810008,
"clientName": "ABC",
"Address": "NYC"
}]
And we have our own custom implementation to return all values excluding certain fields, as follows: It is exposed as separate REST point. Here is the interface method
public interface IUserService {
List<User> getFilteredUsers();
}
and it's implementation is like :
String[] includeFields = new String[]{"idDl", "clientName"};
String[] excludeFields = new String[]{"Address"};
Query searchQuery = new NativeSearchQueryBuilder()
.withQuery(existsQuery("idDl"))
.withSourceFilter(new FetchSourceFilter(includeFields, excludeFields))
.build();
return elasticsearchRestTemplate.queryForList(searchQuery, User.class);
I want to know whether this is interfering with ElasticsearchRepository's findAll()
method in any way. If not then what is the root cause.
来源:https://stackoverflow.com/questions/62771342/get-all-non-full-fields-in-elasticsearchrepositorys-findall-method-in-spring-da