问题
I have this collection in mongodb. my collection:
{
"_id": "5ad2079019551a2108588add",
"brand_name": "MAZOLA LIZA"
"name":"pyd"
}
{
"_id": "5ad2079019551a2108588adf",
"brand_name": "MAZcara"
"name":"rahul"
}
{
"_id": "5ad2079019551a2108588agf",
"brand_name": jk LIZA"
"name":"qa"
}
My desired output:
{
"_id": "5ad2079019551a2108588add",
"brand_name": "MAZOLA LIZA"
"name":"pyd"
}
{
"_id": "5ad2079019551a2108588adf",
"brand_name": "MAZcara"
"name":"rahul"
}
I am trying to get the documents which are contains MOZ in "brand_name"
I am using flask_pymongo for this.
ill send this MOZ using flask method. (method/MOZ)
my code is,
@app.route('/framework/<name>', methods=['GET'])
def get_one_framework(name):
framework = mongo.db.offers
for q in framework.find({"product": {"$regex":"*."+ name+".*"}}):
print(q)
its not printing any records, but i have matching records
来源:https://stackoverflow.com/questions/49843914/how-to-return-documents-which-are-contains-the-specific-keywords-in-the-keys-fro