java - Can't find a codec for class org.springframework.data.mongodb.core.query.GeoCommand -


here code

criteria c = new criteria();     c.andoperator(criteria.where("country").is(country),             criteria.where("createtime").lte(wp),             criteria.where("location").withinsphere(circle),             criteria.where("titlecontent").exists(true));      aggregationoperation match = aggregation.match(c);     aggregationoperation limit = aggregation.limit(20);     aggregationoperation sort = aggregation.sort(new sort(sort.direction.desc, "createtime"));     aggregationoperation group = aggregation.group("titlecontent").sum("count").as("titlecount").count().as("contentcount");     aggregation aggregation = aggregation.newaggregation(match, sort, limit, group);     aggregationresults<titleres> result = template.aggregate(aggregation, "post", titleres.class); 

when add criteria.where("location").withinsphere(circle)

it throw exception

org.bson.codecs.configuration.codecconfigurationexception: can't find codec class org.springframework.data.mongodb.core.query.geocommand 

when remove criteria.where("location").withinsphere(circle)

it ok.

i not know how it.i want data withinsphere.

i worked around problem using geonear command: https://docs.mongodb.com/manual/reference/command/geonear/

remove location criteria , use geonear instead of match:

        nearquery near = nearquery.near(new geojsonpoint(request.getlongitude(), request.getlatitude()));         near = near.maxdistance(request.getdistance() / metrics.miles.getmultiplier());         near = near.num(2000000);//watch out max num default restriction         near = near.spherical(true);         query q = new query();         q.addcriteria(matchcriteria);         near = near.query(q);         aggregationoperation geonear = aggregation.geonear(near, "location"); 

Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -