Near operator isn't ordering items

default discord avatar
wmcmorrow210 months ago

I'm using the near operator to query a list of locations based on their proximity from me. The items seem to be returned in random order instead of the nearest first as defined in the documentation.

const lng = myProfile.location[0]

const lat = myProfile.location[1]

const query = {

location: {

near: [






and: [


subcategories: {

equals: subcategory,





const stringifiedQuery = qs.stringify(


where: query,


{ addQueryPrefix: true },


I'm using Payload 1.9.1. Could this be a bug?

Ahh looks like it's a known issue

Upgrading to the latest version fixed the issue 👍

    Star on GitHub


    Chat on Discord



    Can't find what you're looking for?

    Get help straight from the Payload team with an Enterprise License.