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 8830301
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T08:02:57+00:00 2026-06-14T08:02:57+00:00

In the MongoDB Documentation we’ve got the following example: db.factories.insert( { name: xyz, metro:

  • 0

In the MongoDB Documentation we’ve got the following example:

db.factories.insert( { name: "xyz", metro: { city: "New York", state: "NY" } } );
db.factories.ensureIndex( { metro : 1 } );
// this query can use the above index:
db.factories.find( { metro: { city: "New York", state: "NY" } } );

I’m currently looking for a solution to archieve this query in spring data. My first approach was

Query.query(Criteria.where("metro")
    .andOperator(Criteria.where("city").is("New York")
    .and("state").is("NY")))

but this results in the following query

{ "metro" : { } , "$and" : [ { "city" : "New York" , "state" : "NY"}]}
  • 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-14T08:02:59+00:00Added an answer on June 14, 2026 at 8:02 am

    Finally i found the solution by fiddling around:

    Query.query(Criteria.where("metro").is(
        Query.query(
            Criteria.where("city").is("New York")
            .and("state").is("NY")).getQueryObject()
        )
    )
    // results in { metro: { city: "New York", state: "NY" } }
    

    Hopefully this is the right way to do it…

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

Sidebar

Related Questions

Following MongoDB documentation example seems to be wrong. Any suggestion? a== 1 and a
Current MongoDB documentation states the following: You may only have 1 geospatial index per
in MongoDb I can pass a predicate to an queryable instance for example DataBase.GetCollection<BsonDocument>(entity)
Reading the MongoDB documentation for indexes, i was left a little mystified and unsettled
Per the Mongoose documentation for MongooseJS and MongoDB / Node.js : When your application
I read http://api.mongodb.org/perl/current/MongoDB/Examples.html and seems to be only documentation from mongoDB on Perl. How
I am following examples from http://www.mongodb.org/pages/viewpage.action?pageId=133415 . If I try to set autoReconnect to
From MongoDb documentation: On a query using skip() and limit(), count ignores these parameters
From the C# documentation: The Save method is a combination of Insert and Update.
I'm relatively new to MongoDB and having trouble with a more advanced upsert. I've

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.