1

I have the following record in my MongoDB. I want to search for a string in the "monday" fields. I want to search the "learningexperience" field to return any documents that matches a certain word in that field.

Not sure how to do it using MongoDB/C#. Any help would be fantastic.

{
    "_id" : ObjectId("59ee623844bd6b042809d492"),
    "title" : "Zebra Room (2017-10-30)",
    "weekcommencing" : "2017-10-30", 
    "monday" : [ 
        {
            "categoryid" : "59ee610244bd6b042809d48d",
            "category" : "Culture & Community",
            "learningexperience" : "Dress up to reflect where i am from. Children are asked to dress in the national uniform of their origins."
        }, 
        {
            "categoryid" : "59edca4344bd6d1e200c3c32",
            "category" : "Literacy & Numeracy",
            "learningexperience" : "Today the children will be focusing on simple additions. For those more advance we will also have subtractions in place."
        }
]
}
1

1 Answer 1

1

If you want to search it with something like %keyword%. You may try this

db.tablename.find({"monday.learningexperience": /.*keyword.*/})

For C# you may try this filter (mongodb c# driver 2.0 or higher )

Builders<tablename>.Filter.Regex("monday.learningexperience", new BsonRegularExpression("keyword", "i"));
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.