Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8807071
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T02:17:06+00:00 2026-06-14T02:17:06+00:00

$dm = $this->get(‘doctrine.odm.mongodb.document_manager’); $query = $dm->createQueryBuilder(‘MyBundle:Listing’) ->select(‘title’) ->field(‘coordinates’)->geoNear( (float)$longitude, (float)$latitude )->spherical(true); $classifieds_array = $classifieds->toArray();

  • 0
$dm = $this->get('doctrine.odm.mongodb.document_manager');

$query = $dm->createQueryBuilder('MyBundle:Listing')
            ->select('title')
            ->field('coordinates')->geoNear(
                  (float)$longitude, 
                  (float)$latitude
            )->spherical(true);

$classifieds_array = $classifieds->toArray();

$data = array('success'=>true,'classifieds' => $classifieds_array, 
      'displaymessage' => $classifieds->count(). " Search Results Found");

Even though I am selecting just one field, for my result set, I am getting every thing back in collection along with title. Is this a bug?

NOTE: I commented out the ->field('coordinates')->geoNear((float)$longitude, (float)$latitude)->spherical(true) line and now the select seems to work. This is crazy.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T02:17:07+00:00Added an answer on June 14, 2026 at 2:17 am

    The geoNear command in MongoDB doesn’t seem to support filtering result fields, according to the documentation examples. Only a query option is supported to limit matched documents.

    In your case, it also looks like mixing up the geoNear() and near() builder methods in Doctrine. Since you’re operating on the coordinates field, the appropriate syntax would be near(). geoNear() is a top-level method to tell the builder you wish to use the command, which doesn’t require a field name since it uses the one and only geospatial index on the collection.

    For usage examples, I would advise looking at the query and builder unit tests in the Doctrine MongoDB library.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm getting this GET url through to my php page: suppliersdetails.php?project_no=107&submit=Submit+Query Why would it
My query needs to do this get user details get last login out of
I have c# program, This Get Sql Query From Input and Execute this. Some
How does something like this get initialized in Cpp, when in my main ,
Having a method like this: @GET @Path(/name/{name}) @Produces(MediaType.TEXT_PLAIN) public String getProperty(@PathParam(name) String name) {
what I'm trying to do is this: get the 30 Authors with highest score
I have a route defined like this: GET /question/:q_id controllers.Questions.viewQuestion(q_id: Long) Then in my
Say I have a class that looks like this (get/set omited): class InfoClass{ String
I have a custom cmdlet that can be called like this: Get-Info .\somefile.txt My
Associations: location has_many :comments comment belongs_to :location For some reason, this GET: /locations/5/comments.json is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.