1

Following the examples at: http://docs.doctrine-project.org/projects/doctrine-mongodb-odm/en/latest/reference/query-builder-api.html

I have:

$dm = $this->get('doctrine.odm.mongodb.document_manager');
$query = $dm->createQueryBuilder('MainClassifiedBundle:Listing')->field('residentialOrCommercial')->equals($residentialOrCommercial);
        if ($propertyType != 'All Property Types')
            {
            $query->field('propertyType')->equals($propertyType);
            }

        $query->field('askingPrice')->range($minPrice, $maxPrice)->field('coordinates')->geoNear((float)$longitude, (float)$latitude)->spherical(true);

                if($radius!=0)
                {
                      $query->maxDistance($radius);
                }
        $classifieds = $query->limit(5)->skip(2)->getQuery()->execute();

Everything works fine however the skip field makes no difference whatsoever. No matter if I put 1 or 1000, I am getting the same result set.

What am I missing?

UPDATE: I also tested this on another document collection and found out that it works. Something about the geoNear is what is messing up skip for me.

Strong Like Bull
  • 11,155
  • 36
  • 98
  • 169

1 Answers1

2

geoNear is a database command, rather than a query operator. As such, the limit() and skip() modifiers don't apply to it. See SERVER-3925 for details.

If you'd like to see this functionality in MongoDB, please follow and vote up the Jira ticket.

William Z
  • 10,989
  • 4
  • 31
  • 25