Introduction
Reading your comments I see there is a bit of confusion about what's SolrJ and
Spring Data for Apache Solr.
SolrJ is the Solr client (personally I would also add the standard and official client).
SolrJ is an API that makes it easy for Java applications to talk to
Solr. SolrJ hides a lot of the details of connecting to Solr and
allows your application to interact with Solr with simple high-level
methods.
Spring Data for Apache Solr is part of the larger framework Spring Data and provides configuration and access to Apache Solr Search Server from Spring applications ( to talk with Solr internally it uses SolrJ).
So far, Solr Spring Data ver. 1.2.0.RELEASE depends on SolrJ 4.7.2 which could be incompatibile with Solr 6.2.0 (for sure if you're using SolrCloud).
Given this appropriate introduction I would suggest to keep Solr instance and SolrJ client on the same version (or at least on the same major version).
So for Solr v.6.2.1 you should use SolrJ 6.2.1, but unfortunately latest Solr Spring Data version is 2.1.3.RELEASE (which internally depends on SolrJ 5.5.0).
<dependencies>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-solr</artifactId>
<version>2.1.3.RELEASE</version>
</dependency>
</dependencies>
Your question
Regarding the fact that you don't receive the list of fields you're looking for, simply Solr Data does not support placeholders for the field list.
Instead of struggling with Solr Spring Data, I would suggest to extend your Repository class creating a new RepositoryImpl where add a custom search using the simple and plain SolrJ client.
@Component
public class ProductsRepositoryImpl implements ProductsRepositoryCustom {
@Autowired
private SolrServer solrServer;
public ProductsRepositoryImpl() {};
public ProductsRepositoryImpl(SolrServer solrServer) {
this.solrServer = solrServer;
}
public List<Map<String, Object>> findFields(String id, List<String> fields)
{
SolrQuery solrQuery = new SolrQuery("id:" + id);
solrQuery.setFields(fields.toArray(new String[0]));
try {
QueryResponse response = this.solrServer.query(solrQuery);
return response.getResults()
.stream()
.map(d ->
{
return d.entrySet()
.stream()
.filter(e -> fields.contains(e.getKey()))
.collect(Collectors.toMap(p -> p.getKey(), p -> p.getValue()));
}).collect(Collectors.toList());
} catch (SolrServerException e) {
// TODO Auto-generated catch block
}
return Collections.emptyList();
}
}