Uploaded image for project: 'Spring Data MongoDB'
  1. Spring Data MongoDB
  2. DATAMONGO-1807

Distinct values with geoQuery works in Mongo but not in Spring

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Works as Designed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Repository
    • Labels:
      None

      Description

      While this works in mongo:

      > db.collection.distinct( "key", {"position":{$geoWithin:{$box: [[-6.8, 36.7], [-0.5, 43.8]]}}} )
      > [ "A", "B" ]
      

      In spring returns an error

      Criteria criteria = Criteria.where("position").within(box);
      Query query = new Query();
      query.addCriteria(criteria);
      
      List<String> result = mongoOperations.getCollection("collection")
          .distinct("key", query.getQueryObject());
      
      java.lang.IllegalArgumentException: can't serialize class org.springframework.data.mongodb.core.query.GeoCommand at org.bson.BasicBSONEncoder._putObjectField(BasicBSONEncoder.java:299) ~[mongo-java-driver-2.14.3.jar:na] at org.bson.BasicBSONEncoder.putObject(BasicBSONEncoder.java:194) ~[mongo-java-driver-2.14.3.jar:na] at org.bson.BasicBSONEncoder._putObjectField(BasicBSONEncoder.java:255) ~[mongo-java-driver-2.14.3.jar:na] at org.bson.BasicBSONEncoder.putObject(BasicBSONEncoder.java:194) ~[mongo-java-driver-2.14.3.jar:na] at org.bson.BasicBSONEncoder._putObjectField(BasicBSONEncoder.java:255) ~[mongo-java-driver-2.14.3.jar:na] at org.bson.BasicBSONEncoder.putObject(BasicBSONEncoder.java:194) ~[mongo-java-driver-2.14.3.jar:na] at org.bson.BasicBSONEncoder.putObject(BasicBSONEncoder.java:136) ~[mongo-java-driver-2.14.3.jar:na] at com.mongodb.DefaultDBEncoder.writeObject(DefaultDBEncoder.java:36) ~[mongo-java-driver-2.14.3.jar:na] at com.mongodb.OutMessage.putObject(OutMessage.java:289) ~[mongo-java-driver-2.14.3.jar:na] at com.mongodb.OutMessage.writeQuery(OutMessage.java:211) ~[mongo-java-driver-2.14.3.jar:na] at com.mongodb.OutMessage.query(OutMessage.java:86) ~[mongo-java-driver-2.14.3.jar:na]
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                cstrobl Christoph Strobl
                Reporter:
                pmaraver Patricia Maraver
                Last updater:
                Christoph Strobl
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: