New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add nearSphere to MongodbExpressions. #1438

christophstrobl opened this Issue Jul 17, 2015 · 0 comments


None yet
2 participants

christophstrobl commented Jul 17, 2015

Since $near cannot operate on a 2dsphere index using the legacy coordinate format it would be helpful to have something like a MongodbExpressions.nearSphere.

class MongodbOps {

  // ...
  public static final Operator<Boolean> NEARSPHERE = new OperatorImpl<Boolean>(NS, "NEARSPHERE");

class MongodbExpressions {

  // ...
  public static BooleanExpression nearSphere(Expression<Double[]> expr, double latVal, double longVal) {
    return BooleanOperation.create(MongodbOps.NEARSPHERE, expr, ConstantImpl.create(new Double[]{latVal, longVal}));

class MongodbSerializer {

  public Object visit(Operation<?> expr, Void context) {

    // ...
    } else if (op == MongodbOps.NEARSPHERE) {
      return asDBObject(asDBKey(expr, 0), asDBObject("$nearSphere", asDBValue(expr, 1)));

It would also be nice to have support for $minDistance and $maxDistance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment