def getFilteredQuery(collection, filter, projection={}):
    """Returns the results of the passed query.
    Allows the {"random_count": int} filter which is just a sentinel value
    for {$sample: {size: int}} in the aggregate pipeline.

    [projection] will never allow for the inclusion of _id.
    """
    projection.update({"_id": 0})
    filter = {k: filter[k] for k in filter if filter[k]}
    randomCount = filter.get("random_count", None)
    if randomCount:
        filter = {k: filter[k] for k in filter if k != "random_count"}
        return list(
            collection.aggregate(
                [
                    {"$match": filter},
                    {"$sample": {"size": randomCount}},
                    {"$project": projection},
                ]
            )
        )
    else:
        return [d for d in collection.find(filter, projection)]