Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8313589
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T20:32:16+00:00 2026-06-08T20:32:16+00:00

I have a collection of documents: _id : ObjectId(500d1aa9cf6640c15214fc30), Title : Title0, Description :

  • 0

I have a collection of documents:

  "_id" : ObjectId("500d1aa9cf6640c15214fc30"),
  "Title" : "Title0",
  "Description" : "Description0",
  "Keywords" : ["Keyword000", "Keyword001", "Keyword002", "Keyword003", "Keyword004", "Keyword005", "Keyword006", "Keyword007", "Keyword008", "Keyword009"],
  "Category" : 0

I would like to query for items that have one keyword:

var query = Query.ElemMatch("Keywords", Query.EQ(XXX, "Keyword003"));

I have no idea on what to query on Query.EQ.


By turning the example into:

"_id" : ObjectId("500d4393cf6640c152152354"),
"Title" : "Title0",
"Description" : "Description0",
"Keywords" : [{
  "Value" : "Keyword000"
}, {
  "Value" : "Keyword001"
}],
"Category" : 0

And querying by

var query = Query.ElemMatch("Keywords", Query.EQ("Value", "Keyword001"));

I have no problem on getting the results.

Thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T20:32:19+00:00Added an answer on June 8, 2026 at 8:32 pm

    The MongoDB query engine treats queries of the form { x : 123 } differently when x is an array. It matches any document where the x array contains 123. See:

    http://www.mongodb.org/display/DOCS/Advanced+Queries#AdvancedQueries-ValueinanArray

    In your case, the query:

    Query.EQ("Keywords", "Keyword003")
    

    will match any document where the Keywords array contains “Keyword003”. It might also contain other values, but that doesn’t matter.

    ElemMatch is only needed when the array is an array of embedded documents and you want to write a complex test against each of the embedded documents.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have some embedded documents that look like this: { _id : ObjectId(4e402353bc9f6ec5a6000001), first_name
I have a document collection like this: { _id : ObjectId(4fb21439f31dfd122ce39c4a), Name : Freelander
I have one document in my params collection like this: { _id: ObjectId(4d124cef3ffcf6f410000037), code:
I have a MongoDB collection with documents in the following format: { _id :
If I have several documents that use the following structure: { _id : ObjectId(4f9c6fe033cddec1bea430f2),
I have 10000 documents in one MongoDB collection. I'd like to update all the
Lets say I have collection of documents with specified longitude and latitude. type is
for example I have collection foo of documents like that: {tag_cloud:[{value:games, count:10}, {value:girls, count:500}]}
I have a collection with nested documents in it. Each document also has an
I have a mongo collection which has documents with two fields fieldA and fieldB,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.