Mongo collection query and Operators

社会主义新天地 提交于 2019-12-24 02:24:31

问题


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


回答1:


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

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




回答2:


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.



来源:https://stackoverflow.com/questions/13385043/mongo-collection-query-and-operators

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!