I want to search MongoDB so that I get only results where all x are found in some configuration together in the key.
collected_x = ''
for x in input:
collected_x = collected_x + 're.compile("' + x + '"), '
collected_x_cut = collected_x[:-2]
cursor = db.collection.find({"key": {"$all": [collected_x_cut]}})
This does not bring the anticipated result. If I input the multiple x by themselves, it works.
cursor = db.collection.find({"key": {"$all": [re.compile("Firstsomething"),
re.compile("Secondsomething"),
re.compile("Thirdsomething"),
re.compile("Fourthsomething")]}})
What am I doing wrong?