mongodb find by multiple array items

Depends on whether you’re trying to find documents where words contains both elements (text and here) using $all:

db.things.find({ words: { $all: ["text", "here"] }});

or either of them (text or here) using $in:

db.things.find({ words: { $in: ["text", "here"] }});

Leave a Comment