Я использую агрегацию следующим образом:
final List<AggregationOperation> aggregations = new ArrayList<>();
Polygon polygon = new Polygon(new Point(-26.28125, 42.19231862526141), new Point(100.28125, 64.7157757187955),
new Point(100.28125, 42.19231862526141), new Point(-26.28125, 64.7157757187955));
AggregationOperation match = new MatchOperation(Criteria.where("location").within(polygon));
aggregationOperations.add(match);
aggregations.add(project("_id", "location","distance",User.COLLECTION_NAME)
.and("$geoHash").substring(0,slice).as("geo"));
aggregations.add(group("geo").count().as("count")
.avg("location.lng").as("lon")
.avg("location.lat").as("lat")
.first(User.COLLECTION_NAME).as(User.COLLECTION_NAME));
final Aggregation aggregation = newAggregation(aggregations);
AggregationResults<ClusteredLocation> groupResults =
mongoTemplate.aggregate(aggregation, UserLocation.COLLECTION_NAME, ClusteredLocation.class);
return groupResults.getMappedResults();
Агрегирование, которое создается следующим образом: {"aggregate": " collection ", "pipe": [{"$ match ": {" location ": {" $ geoWithin ": {" $ java ": org.springframework.data.mongodb.core.query.GeoCommand@d502fd15}}}}, {" $ lookup ": {" from":" users "," localField ":" _id "," foreignField ":" _id "," as ":" users "}}, {" $ project ": {" _id ": 1," location ": 1, "distance": 1, "users": 1, "geo": {"$ substr": ["$ geoHash", 0, 3]}}}, {"$ group": {"_id": "$geo "," count ": {" $ sum ": 1}," lon ": {" $ avg ":" $ location.lng "}," lat ": {" $ avg ":" $ location.lat "}, "users": {"$ first": "$ users"}}}]}
Исключение Я получаю следующим образом:
org.bson.codecs.configuration.CodecConfigurationException:Не удается найти кодек для класса org.springframework.data.mongodb.core.query.GeoCommand.
Я что-то не так делаю в операции сопоставления?