解决方法一
To set fl you have to use query.addProjectionOnField(String fieldname).
SimpleQuery query = new SimpleQuery(conditions);
query.addProjectionOnField("*");
query.addProjectionOnField("score");
For mapping score into EventDocument you’ll have to add the property as follows.
@Indexed(value = "score", readonly = true)
private Float score;
Unfortunately there seems to be an issue with geodist() that might be caused by the way spring data solr creates spatial query. Opended DATASOLR-130 for that.
Distance can be requested using SolrCallback along with SolrTemplate by setting spatial paramters yourself.
SimpleQuery query = new SimpleQuery(conditions);
query.addProjectionOnField("*");
query.addProjectionOnField("distance:geodist()");
DefaultQueryParser qp = new DefaultQueryParser();
final SolrQuery solrQuery = qp.constructSolrQuery(query);
solrQuery.add("sfield", "store");
solrQuery.add("pt", GeoConverters.GeoLocationToStringConverter.INSTANCE.convert(new GeoLocation(45.15, -93.85)));
solrQuery.add("d", GeoConverters.DistanceToStringConverter.INSTANCE.convert(new Distance(5)));
List<EventDocument> result = template.execute(new SolrCallback<List<EventDocument>>() {
@Override
public List