Mongo collection query and Operators

2019-07-18 09:37发布

From my collection I just want to return records that have either location or place information (Coordinates included) in the records. So if either condition is not null then it retrieves either or both fields if both conditions are not null.

My query is this so far:

        cursor = coll.find({"$or" : [{"place.bounding_box.type" : {"$ne" : None }}, {"coordinates.type" : {"$ne" : None }}]}, {"coordinates.coordinates" :1},
              {"place.bounding_box.coordinates" : 1}, tailable = True, timeout = False)

But I get this pymongo error:

raise TypeError("skip must be an instance of int")
TypeError: skip must be an instance of int

I can get the queries to work separately but not in a join query as above.

Thanks

2条回答
走好不送
2楼-- · 2019-07-18 10:09

I'm not familiar with pymongo, but MongoDB doesn't support joins... You will need to run the two queries separately, and join the results.

查看更多
Emotional °昔
3楼-- · 2019-07-18 10:19

That error sounds like you are doing a .skip("string") on the results cursor.

Also, you should have a read on $exists as well.

查看更多
登录 后发表回答