Hello, i was trying to do a array search using the query language however my db.collection.find() returns nothing this is my code:
from pymongo import MongoClient
client = MongoClient("mongodb://localhost:27017")
db = client.get_database('MapView')
neighborhood = db.bairroSP
restaurant= db.resSpec
search_restaurant = restaurant.find({'type':['meat','fish']})
for rest in search_restaurant:
print(rest)
And here it’s the return:
C:\Users\André\AppData\Local\Programs\Python\Python37\python.exe
C:/Users/André/PycharmProjects/PythonDB/testes.py
Process finished with exit code 0
Here are some of the documents from my collection:
{“_id”:1, “location”:{“coordinates”:[-46.665958,-23.563313] ,“type”:“Point”},“type”:[“fish”, “seafood],“preco”:39.25,“name”:“Barú Marisquería”}
{”_id":2, “location”:{“coordinates”:[-46.697364,-23.559586] ,“type”:“Point”},“type”:[ “fish”, “seafood”, “meat”],“preco”:30.00,“name”:“Costa Nova”}
{“_id”:3, “location”:{“coordinates”:[-46.668611,-23.561079] ,“type”:“Point”},“type”:[“fish”, “seafood”, “meat”],“preco”:30.00,“name”:“Costa Nova”}
My objective is to get all documents with this both types of food in the array, doesn’t matter if they’re in the same array or in different arrays