I have been trying some queries and had an issue so posting here for some help.
here is a sample JSON how it looks like
{
"_id": {
"$oid": "5f82cb362ce0b715157bf903"
},
"show_id": 81145628,
"type": "Movie",
"title": "Norm of the North: King Sized Adventure",
"director": "Richard Finn, Tim Maltby",
"cast": "Alan Marriott, Andrew Toth, Brian Dobson, Cole Howard, Jennifer Cameron, Jonathan Holmes, Lee Tockar, Lisa Durupt, Maya Kay, Michael Dobson",
"country": "United States, India, South Korea, China",
"date_added": "9-Sep-19",
"release_year": 2019,
"rating": "TV-PG",
"duration": "90 min",
"listed_in": "Children & Family Movies, Comedies",
"description": "Before planning an awesome wedding for his grandfather, a polar bear king must take back a stolen artifact from an evil archaeologist first."
}
Here is my query
query = [
{
"$facet": {
"Title": [
{
"$unwind": "$title"
},
{
"$sortByCount": "$title"
},
{
"$limit": 7
},
]
}
}
]
CONNECTION_URL = "mongodb://root:rootpassword@localhost:27017"
client = MongoClient(host=CONNECTION_URL)
d = client['movies']['movie'].aggregate(query1)
for x in d:
print(x)
This works fine, but I want to filter out and do aggregation go an aggregation where movie title starts with n* something like that. I tried a few options that seem to be not working. Any help would be great.