my document has a field called 'tags', which is an array of string. I'm trying to search for documents that contains 'keyword' in 'tags'. However, this doesn't seem to work on Azure Cosmos DB. Any help is appreciated.
Edit: I replaced my previous post with more complete code sample, as one of the commenters requested.
const MongoClient = require('mongodb').MongoClient;
const mongoConnectionString = process.env.MONGODB_CONNECTION_STRING;
const mongoOptions =
{
connectTimeoutMS: 0
}
var mongoDB;
MongoClient.connect(mongoConnectionString, (err, db) => {
if (err) throw err;
mongoDB = db.db('mydb');
mongoDB.collection('mycol', (err, collection) => {
if (err) throw err;
collection.find(
{tags: {$in:['keyword']}},
(err, cursor) => {
if (err) throw(err);
cursor.toArray((err, docs) => {
for (i = 0; i < docs.length; i++) {
console.log(JSON.stringify(docs));
db.close();
}
});
}
);
});
});