MongoEngine / MongoEngine/mongoengine
location object expected, location array not in correct format
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 4.3k
- Forks
- 1.2k
- Avg merge
- 4h 41m
- Merged PRs (30d)
- 11
Description
mongoengine 0.19.1
os: OS X
I have a field for geo point called location as below inside of geoip field:
"geoip" : { "continent" : "asia", "country" : "China", "country_code" : "CN", "latitude" : 1.01211, "longitude" : 0.71283, "timezone" : "Asia/Pacific", "city" : "", "area_code" : "", "location" : { "type" : "Point", "coordinates" : [ -0.15261409999993703, 51.4428321 ] } }
Now getting indexes displays that I have a 2dsphere index:
{
"v" : 2,
"key" : {
"geoip.location" : "2dsphere"
},
"name" : "loc_idx",
"ns" : "sample_db.users",
"background" : false,
"2dsphereIndexVersion" : 3
}
Now my query in mongoengine is as follow:
[{'$geoNear': {'near': {'type': 'Point',
'coordinates': ['-0.15261409999993703', 51.4428321]},
'distanceField': 'geoip.location',
'query': {'$or': [{'name': {'$regex': '.*domain.com'}},
{'name': '172.16.131.12'}]}}}]
But when I run the below command I get an error:
result = list(Users.objects.aggregate(*geo_pipe))
pymongo.errors.OperationFailure: location object expected, location array not in correct format
Interesting part is that the same query works on mongo shell. Is this a bug?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the aggregate call with the shown geo_pipe and compare it with the working Mongo shell query. Inspect how the aggregate pipeline is passed through MongoEngine, especially the $geoNear near coordinates, and use the differing behavior to isolate the discrepancy. Done means the Python aggregate accepts the same valid location format as the shell query, with a regression test covering it.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- mongodb, python
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100