java mongodb geonear using query class The 2019 Stack Overflow Developer Survey Results Are InHow to query MongoDB with “like”?MongoDB 'unable to find index for $geoNear query'Mongo (+Mongoose) error: Unable to find index for $geoNear query2dsphere index in MongoDB collection is not fetching in spring JavaUse variables in geonear aggregator in Python Eve with MongoDBMongoDB $geoNear aggregation pipeline (using query option and using $match pipeline operation) giving different no of resultsQuery complains about missing 2dsphere-index, but it's thereLaravel MongoDB : unable to find index for $geoNearHow can i specify the index(key, field) in geoNear (error code: 16604)Unable to find elements by 2sphere

How did passengers keep warm on sail ships?

How to type a long/em dash `—`

Why doesn't UInt have a toDouble()?

Does adding complexity mean a more secure cipher?

Falsification in Math vs Science

Accepted by European university, rejected by all American ones I applied to? Possible reasons?

Pokemon Turn Based battle (Python)

Does HR tell a hiring manager about salary negotiations?

Straighten subgroup lattice

Can there be female White Walkers?

What is this sharp, curved notch on my knife for?

Can I have a signal generator on while it's not connected?

Why not take a picture of a closer black hole?

Correct punctuation for showing a character's confusion

Inverse Relationship Between Precision and Recall

Can an undergraduate be advised by a professor who is very far away?

How to obtain a position of last non-zero element

Are there any other methods to apply to solving simultaneous equations?

Keeping a retro style to sci-fi spaceships?

Can you cast a spell on someone in the Ethereal Plane, if you are on the Material Plane and have the True Seeing spell active?

Is Cinnamon a desktop environment or a window manager? (Or both?)

Getting crown tickets for Statue of Liberty

Likelihood that a superbug or lethal virus could come from a landfill

Can we generate random numbers using irrational numbers like π and e?



java mongodb geonear using query class



The 2019 Stack Overflow Developer Survey Results Are InHow to query MongoDB with “like”?MongoDB 'unable to find index for $geoNear query'Mongo (+Mongoose) error: Unable to find index for $geoNear query2dsphere index in MongoDB collection is not fetching in spring JavaUse variables in geonear aggregator in Python Eve with MongoDBMongoDB $geoNear aggregation pipeline (using query option and using $match pipeline operation) giving different no of resultsQuery complains about missing 2dsphere-index, but it's thereLaravel MongoDB : unable to find index for $geoNearHow can i specify the index(key, field) in geoNear (error code: 16604)Unable to find elements by 2sphere



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








1















I am trying to find the documents which are near to a point without using aggregation.I want use NearQuery or Query class or any other.



I tried with following queries but getting exception



1)



 NearQuery n=NearQuery.near(user.getLoc().get(0),user.getLoc().get(1)); 
GeoResults<User> results=mongoTemplate.geoNear(n,User.class,"User4",User.class);


2)



 Point point= new Point(77.6672961,13.0257889);
Query query= new Query(Criteria.where("loc").nearSphere(point));
List<User> nearbyusers=mongoTemplate.find(query, User.class,"User4");


3)



 Point p=new Point(13.0257889,77.6672961);
Query q=new Query(Criteria.where("loc").near(p));
List<User> i=mongoTemplate.find(q,User.class,"User4");


Exception:



org.springframework.data.mongodb.UncategorizedMongoDbException: Command failed with error 2 (BadValue): 'error processing query: ns=CitizenChat4.User4 limit=100Tree: GEONEAR field=loc maxdist=1.79769e+308 isNearSphere=0
Sort:
Proj: $pt: $meta: "geoNearPoint" , $dis: $meta: "geoNearDistance"
planner returned error: unable to find index for $geoNear query' on server localhost:27017. The full response is "ok" : 0.0, "errmsg" : "error processing query: ns=CitizenChat4.User4 limit=100Tree: GEONEAR field=loc maxdist=1.79769e+308 isNearSphere=0nSort: nProj: $pt: $meta: "geoNearPoint" , $dis: $meta: "geoNearDistance" n planner returned error: unable to find index for $geoNear query", "code" : 2, "codeName" : "BadValue" ; nested exception is com.mongodb.MongoCommandException: Command failed with error 2 (BadValue): 'error processing query: ns=CitizenChat4.User4 limit=100Tree: GEONEAR field=loc maxdist=1.79769e+308 isNearSphere=0
Sort:
Proj: $pt: $meta: "geoNearPoint" , $dis: $meta: "geoNearDistance"
planner returned error: unable to find index for $geoNear query' on server localhost:27017. The full response is "ok" : 0.0, "errmsg" : "error processing query: ns=CitizenChat4.User4 limit=100Tree: GEONEAR field=loc maxdist=1.79769e+308 isNearSphere=0nSort: nProj: $pt: $meta: "geoNearPoint" , $dis: $meta: "geoNearDistance" n planner returned error: unable to find index for $geoNear query", "code" : 2, "codeName" : "BadValue"
at org.springframework.data.mongodb.core.MongoExceptionTranslator.translateExceptionIfPossible(MongoExceptionTranslator.java:138)
at org.springframework.data.mongodb.core.MongoTemplate.potentiallyConvertRuntimeException(MongoTemplate.java:2756)
at org.springframework.data.mongodb.core.MongoTemplate.execute(MongoTemplate.java:510)


User4 collection:



 "userID" : "1",
"user_Email" : "ghjkl@gmail.com",
"loc" : [
77.618843,
13.052758
]

"userID" : "2",
"user_Email" : "abc@gmail.com",
"loc" : [
77.618743,
13.054518
]


I have created 2dsphere index on loc attribute in user4 collection.



index:




"v" : 2,
"key" :
"loc" : "2dsphere"
,
"name" : "loc_2dsphere",
"ns" : "CitizenChat4.User4",
"2dsphereIndexVersion" : 3



Please help me.Thankyou










share|improve this question




























    1















    I am trying to find the documents which are near to a point without using aggregation.I want use NearQuery or Query class or any other.



    I tried with following queries but getting exception



    1)



     NearQuery n=NearQuery.near(user.getLoc().get(0),user.getLoc().get(1)); 
    GeoResults<User> results=mongoTemplate.geoNear(n,User.class,"User4",User.class);


    2)



     Point point= new Point(77.6672961,13.0257889);
    Query query= new Query(Criteria.where("loc").nearSphere(point));
    List<User> nearbyusers=mongoTemplate.find(query, User.class,"User4");


    3)



     Point p=new Point(13.0257889,77.6672961);
    Query q=new Query(Criteria.where("loc").near(p));
    List<User> i=mongoTemplate.find(q,User.class,"User4");


    Exception:



    org.springframework.data.mongodb.UncategorizedMongoDbException: Command failed with error 2 (BadValue): 'error processing query: ns=CitizenChat4.User4 limit=100Tree: GEONEAR field=loc maxdist=1.79769e+308 isNearSphere=0
    Sort:
    Proj: $pt: $meta: "geoNearPoint" , $dis: $meta: "geoNearDistance"
    planner returned error: unable to find index for $geoNear query' on server localhost:27017. The full response is "ok" : 0.0, "errmsg" : "error processing query: ns=CitizenChat4.User4 limit=100Tree: GEONEAR field=loc maxdist=1.79769e+308 isNearSphere=0nSort: nProj: $pt: $meta: "geoNearPoint" , $dis: $meta: "geoNearDistance" n planner returned error: unable to find index for $geoNear query", "code" : 2, "codeName" : "BadValue" ; nested exception is com.mongodb.MongoCommandException: Command failed with error 2 (BadValue): 'error processing query: ns=CitizenChat4.User4 limit=100Tree: GEONEAR field=loc maxdist=1.79769e+308 isNearSphere=0
    Sort:
    Proj: $pt: $meta: "geoNearPoint" , $dis: $meta: "geoNearDistance"
    planner returned error: unable to find index for $geoNear query' on server localhost:27017. The full response is "ok" : 0.0, "errmsg" : "error processing query: ns=CitizenChat4.User4 limit=100Tree: GEONEAR field=loc maxdist=1.79769e+308 isNearSphere=0nSort: nProj: $pt: $meta: "geoNearPoint" , $dis: $meta: "geoNearDistance" n planner returned error: unable to find index for $geoNear query", "code" : 2, "codeName" : "BadValue"
    at org.springframework.data.mongodb.core.MongoExceptionTranslator.translateExceptionIfPossible(MongoExceptionTranslator.java:138)
    at org.springframework.data.mongodb.core.MongoTemplate.potentiallyConvertRuntimeException(MongoTemplate.java:2756)
    at org.springframework.data.mongodb.core.MongoTemplate.execute(MongoTemplate.java:510)


    User4 collection:



     "userID" : "1",
    "user_Email" : "ghjkl@gmail.com",
    "loc" : [
    77.618843,
    13.052758
    ]

    "userID" : "2",
    "user_Email" : "abc@gmail.com",
    "loc" : [
    77.618743,
    13.054518
    ]


    I have created 2dsphere index on loc attribute in user4 collection.



    index:




    "v" : 2,
    "key" :
    "loc" : "2dsphere"
    ,
    "name" : "loc_2dsphere",
    "ns" : "CitizenChat4.User4",
    "2dsphereIndexVersion" : 3



    Please help me.Thankyou










    share|improve this question
























      1












      1








      1








      I am trying to find the documents which are near to a point without using aggregation.I want use NearQuery or Query class or any other.



      I tried with following queries but getting exception



      1)



       NearQuery n=NearQuery.near(user.getLoc().get(0),user.getLoc().get(1)); 
      GeoResults<User> results=mongoTemplate.geoNear(n,User.class,"User4",User.class);


      2)



       Point point= new Point(77.6672961,13.0257889);
      Query query= new Query(Criteria.where("loc").nearSphere(point));
      List<User> nearbyusers=mongoTemplate.find(query, User.class,"User4");


      3)



       Point p=new Point(13.0257889,77.6672961);
      Query q=new Query(Criteria.where("loc").near(p));
      List<User> i=mongoTemplate.find(q,User.class,"User4");


      Exception:



      org.springframework.data.mongodb.UncategorizedMongoDbException: Command failed with error 2 (BadValue): 'error processing query: ns=CitizenChat4.User4 limit=100Tree: GEONEAR field=loc maxdist=1.79769e+308 isNearSphere=0
      Sort:
      Proj: $pt: $meta: "geoNearPoint" , $dis: $meta: "geoNearDistance"
      planner returned error: unable to find index for $geoNear query' on server localhost:27017. The full response is "ok" : 0.0, "errmsg" : "error processing query: ns=CitizenChat4.User4 limit=100Tree: GEONEAR field=loc maxdist=1.79769e+308 isNearSphere=0nSort: nProj: $pt: $meta: "geoNearPoint" , $dis: $meta: "geoNearDistance" n planner returned error: unable to find index for $geoNear query", "code" : 2, "codeName" : "BadValue" ; nested exception is com.mongodb.MongoCommandException: Command failed with error 2 (BadValue): 'error processing query: ns=CitizenChat4.User4 limit=100Tree: GEONEAR field=loc maxdist=1.79769e+308 isNearSphere=0
      Sort:
      Proj: $pt: $meta: "geoNearPoint" , $dis: $meta: "geoNearDistance"
      planner returned error: unable to find index for $geoNear query' on server localhost:27017. The full response is "ok" : 0.0, "errmsg" : "error processing query: ns=CitizenChat4.User4 limit=100Tree: GEONEAR field=loc maxdist=1.79769e+308 isNearSphere=0nSort: nProj: $pt: $meta: "geoNearPoint" , $dis: $meta: "geoNearDistance" n planner returned error: unable to find index for $geoNear query", "code" : 2, "codeName" : "BadValue"
      at org.springframework.data.mongodb.core.MongoExceptionTranslator.translateExceptionIfPossible(MongoExceptionTranslator.java:138)
      at org.springframework.data.mongodb.core.MongoTemplate.potentiallyConvertRuntimeException(MongoTemplate.java:2756)
      at org.springframework.data.mongodb.core.MongoTemplate.execute(MongoTemplate.java:510)


      User4 collection:



       "userID" : "1",
      "user_Email" : "ghjkl@gmail.com",
      "loc" : [
      77.618843,
      13.052758
      ]

      "userID" : "2",
      "user_Email" : "abc@gmail.com",
      "loc" : [
      77.618743,
      13.054518
      ]


      I have created 2dsphere index on loc attribute in user4 collection.



      index:




      "v" : 2,
      "key" :
      "loc" : "2dsphere"
      ,
      "name" : "loc_2dsphere",
      "ns" : "CitizenChat4.User4",
      "2dsphereIndexVersion" : 3



      Please help me.Thankyou










      share|improve this question














      I am trying to find the documents which are near to a point without using aggregation.I want use NearQuery or Query class or any other.



      I tried with following queries but getting exception



      1)



       NearQuery n=NearQuery.near(user.getLoc().get(0),user.getLoc().get(1)); 
      GeoResults<User> results=mongoTemplate.geoNear(n,User.class,"User4",User.class);


      2)



       Point point= new Point(77.6672961,13.0257889);
      Query query= new Query(Criteria.where("loc").nearSphere(point));
      List<User> nearbyusers=mongoTemplate.find(query, User.class,"User4");


      3)



       Point p=new Point(13.0257889,77.6672961);
      Query q=new Query(Criteria.where("loc").near(p));
      List<User> i=mongoTemplate.find(q,User.class,"User4");


      Exception:



      org.springframework.data.mongodb.UncategorizedMongoDbException: Command failed with error 2 (BadValue): 'error processing query: ns=CitizenChat4.User4 limit=100Tree: GEONEAR field=loc maxdist=1.79769e+308 isNearSphere=0
      Sort:
      Proj: $pt: $meta: "geoNearPoint" , $dis: $meta: "geoNearDistance"
      planner returned error: unable to find index for $geoNear query' on server localhost:27017. The full response is "ok" : 0.0, "errmsg" : "error processing query: ns=CitizenChat4.User4 limit=100Tree: GEONEAR field=loc maxdist=1.79769e+308 isNearSphere=0nSort: nProj: $pt: $meta: "geoNearPoint" , $dis: $meta: "geoNearDistance" n planner returned error: unable to find index for $geoNear query", "code" : 2, "codeName" : "BadValue" ; nested exception is com.mongodb.MongoCommandException: Command failed with error 2 (BadValue): 'error processing query: ns=CitizenChat4.User4 limit=100Tree: GEONEAR field=loc maxdist=1.79769e+308 isNearSphere=0
      Sort:
      Proj: $pt: $meta: "geoNearPoint" , $dis: $meta: "geoNearDistance"
      planner returned error: unable to find index for $geoNear query' on server localhost:27017. The full response is "ok" : 0.0, "errmsg" : "error processing query: ns=CitizenChat4.User4 limit=100Tree: GEONEAR field=loc maxdist=1.79769e+308 isNearSphere=0nSort: nProj: $pt: $meta: "geoNearPoint" , $dis: $meta: "geoNearDistance" n planner returned error: unable to find index for $geoNear query", "code" : 2, "codeName" : "BadValue"
      at org.springframework.data.mongodb.core.MongoExceptionTranslator.translateExceptionIfPossible(MongoExceptionTranslator.java:138)
      at org.springframework.data.mongodb.core.MongoTemplate.potentiallyConvertRuntimeException(MongoTemplate.java:2756)
      at org.springframework.data.mongodb.core.MongoTemplate.execute(MongoTemplate.java:510)


      User4 collection:



       "userID" : "1",
      "user_Email" : "ghjkl@gmail.com",
      "loc" : [
      77.618843,
      13.052758
      ]

      "userID" : "2",
      "user_Email" : "abc@gmail.com",
      "loc" : [
      77.618743,
      13.054518
      ]


      I have created 2dsphere index on loc attribute in user4 collection.



      index:




      "v" : 2,
      "key" :
      "loc" : "2dsphere"
      ,
      "name" : "loc_2dsphere",
      "ns" : "CitizenChat4.User4",
      "2dsphereIndexVersion" : 3



      Please help me.Thankyou







      mongodb spring-data-mongodb spring-mongodb spring-mongo mongodb-geospatial






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 8 at 11:07









      nithinnithin

      647




      647






















          0






          active

          oldest

          votes












          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55061923%2fjava-mongodb-geonear-using-query-class%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55061923%2fjava-mongodb-geonear-using-query-class%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Save data to MySQL database using ExtJS and PHP [closed]2019 Community Moderator ElectionHow can I prevent SQL injection in PHP?Which MySQL data type to use for storing boolean valuesPHP: Delete an element from an arrayHow do I connect to a MySQL Database in Python?Should I use the datetime or timestamp data type in MySQL?How to get a list of MySQL user accountsHow Do You Parse and Process HTML/XML in PHP?Reference — What does this symbol mean in PHP?How does PHP 'foreach' actually work?Why shouldn't I use mysql_* functions in PHP?

          Compiling GNU Global with universal-ctags support Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Tags for Emacs: Relationship between etags, ebrowse, cscope, GNU Global and exuberant ctagsVim and Ctags tips and trickscscope or ctags why choose one over the other?scons and ctagsctags cannot open option file “.ctags”Adding tag scopes in universal-ctagsShould I use Universal-ctags?Universal ctags on WindowsHow do I install GNU Global with universal ctags support using Homebrew?Universal ctags with emacsHow to highlight ctags generated by Universal Ctags in Vim?

          Add ONERROR event to image from jsp tldHow to add an image to a JPanel?Saving image from PHP URLHTML img scalingCheck if an image is loaded (no errors) with jQueryHow to force an <img> to take up width, even if the image is not loadedHow do I populate hidden form field with a value set in Spring ControllerStyling Raw elements Generated from JSP tagds with Jquery MobileLimit resizing of images with explicitly set width and height attributeserror TLD use in a jsp fileJsp tld files cannot be resolved