Skip to main content

Questions tagged [mongodb-query]

This tag is for questions related to querying and updating MongoDB collections, either through the mongo shell or using a programming language driver.

mongodb-query
0 votes
0 answers
9 views

MongoDB text search with text indexes slower than using $regex

I have a shoes collection with about 1.4 millions records. I tried to get list of shoes containing "Adidas Men's Clinch-X M Running Shoe" phrase. At first, I did not index the "name&...
untaminh1's user avatar
3 votes
1 answer
41 views

How can I filter an ISODate field based only the in the time in MongoDB

I have a collection with the following structure in MongoDB: { "Name": "Test", "StartDatetime": ISODate('2024-05-15T15:00:41.180+00:00'), "...
Guilherme Santana's user avatar
0 votes
0 answers
13 views

Why is parameter allowDiskUse is not working in my JasperReport using MongoDB aggregation query

I've created a Jasper Report using an aggregation pipeline from a MongoDB data source and everything was working properly with small amount of data but now that we have more and more data this query ...
Max Athöz's user avatar
1 vote
1 answer
30 views

mongod multi nested is not working as expected

I have some doubts with $in here , I have following type of documents in my db: { "a": [ { "p": [ { "pid": { "CC": "A"...
R2D2's user avatar
  • 10.4k
-1 votes
0 answers
26 views

I want to sort my data according to nearest location

Hi i want to get data nearby location for that I am providing coordinates so its giving right data but I want all data in sorting order by coordinates like I have searched for vadodara then it should ...
sachin jogchand's user avatar
0 votes
0 answers
16 views

Unable to query using Reference id in morphia 2.4.14 for Reference entity. use of Key<> is deprecated

I have an Entity Book. It contains Language entity. Language entity is stored as DBRef() in database. I need DBRef. @Entity("Book") class Book{ @Reference(language_id) private Language ...
mandar shinde's user avatar
0 votes
0 answers
52 views

Mongo Data API find documents count

Can the total document count be extracted using Mongo Data API? If there are a million records in the Mongo DB collection I need the count. Tried with Mongo data API /find the endpoint. But not sure ...
techqueries's user avatar
1 vote
1 answer
28 views

Create array of elements based on another existing array using MongoDB Aggregation

I need to take a field from a document as input, like below: "participants": ["John", "Peter"], and make the output field like that: "participants": [ { ...
Mathias Hillesheim's user avatar
-2 votes
0 answers
20 views

In a time-series collection get price 5m, 10m, 1 hour and 24 hours ago [closed]

I have a MongoDB time series collection that stores prices information. It has following schema { timestamp: ISODate(), token: String, price: Decimal128 } I want to fetch a list of all tokens, where ...
R Artur's user avatar
  • 17
-5 votes
0 answers
32 views

how to find document inside array in mogodb [closed]

This is mongodb modal new Schema( { mrp: { type: Number, required: true }, selling_price: { type: Number, required: true ...
Ravi Gupta's user avatar
0 votes
1 answer
35 views

Mongo How to get only available documents by date

I have documents that associated to students: [ { '_id': 1, 'name': 'Anna', 'vacation_start: '2024-01-01', 'vacation_end': '2024-01-03' }, { '_id': 2, 'name': 'Bob', 'vacation_start: '2024-01-01', '...
Zesshi's user avatar
  • 481
0 votes
1 answer
51 views

Batch update of records in MongoDB

I iterated over records in the batch step and in Batch Aggregator I wanted to update all of them at once in mongoDb. Is there a way to update them all together or I need to separately update each one ...
Антон Олег's user avatar
-1 votes
1 answer
19 views

I've been trying to apply unique index in combination in mongoDb databse using in my node.js backend, but unable to get away with the duplicate error

The movie is supposed to be added to the single document named as watchlist of all user, but i tried to apply unique index in combination of profile_id(user) and content_id(movie_id) so that same ...
Arish Ali's user avatar
0 votes
1 answer
23 views

Add a field inside an array within a MongoDB object, with values computed dynamically based on other values inside the same nested array

I have a simple MongoDB array of objects with this structure: [ { "_id": { "$oid": "6688c2f6b79f2bfefb751d5f" }, "date": "06/07/2024&...
vgeorg's user avatar
  • 3
0 votes
0 answers
21 views

Mongo DB Atlas | Aggregation not getting response

Am doing a personal project and using MongoDB Atlas for storing documents. I have the below code app.get('/admin/dashboard', (req, res) => { console.log('Received request for admin ...
Sunil's user avatar
  • 561
1 vote
1 answer
35 views

MongoDB query for points with cutout

In my lootPoint collection I have the data like this: { "_id" : "1856132932", "point" : { "type" : "Point", "coordinates&...
injecteer's user avatar
  • 20.5k
0 votes
0 answers
22 views

Mongodb query doesn't post or put data in deploy

I'm developing a simple forum website. It has a react frontend + node backend, with mongodb cloud as database and AWS Cognito for signup/ verification/ sign in. When a user signs up: 1. create a user ...
Leah's user avatar
  • 1
1 vote
3 answers
46 views

How to convert a positive integer to binary inside mongoDB aggregation

I was looking for a way to convert a positive integer into a binary array inside a mongoDB aggregation pipeline. There is $bit operation which can't be used inside an aggregation pipeline. This ...
nimrod serok's user avatar
  • 15.9k
0 votes
0 answers
31 views

Problems with my query in the json validator

[ { $addFields: { Larva: { $toInt: "$Larva" }, Ninfa: { $toInt: "$Ninfa" }, Pupa: { $toInt: "$Pupa" }, } }, { $group: { ...
Victor Daniel Salazar Marquez's user avatar
1 vote
1 answer
71 views

How to write an efficient mongo query for complex structures

I am using express/nodejs(without mongoose) and mongodb as my database. I have a collection Pages which looks something like this { _id: .. Urls: [ { IncomingUrl: "/test/test1",...
Jayendra Awasthi's user avatar
2 votes
1 answer
48 views

How to exclude number in MongoDB filter $gte and $lte

I have a MongoDB document with number field: [ { _id: 1, number: 10 }, { _id: 2, number: 11 }, { _id: 3, number: 12 } ] And I'm using MongoDB filter $gte and $lte ...
Zesshi's user avatar
  • 481
1 vote
2 answers
55 views

MongoDB update single primitive in an array

I needed to run a quick and (I thought) trivial query to update some incorrect data. I'm trying to update the very first entry of an array in a document. Note: My posted queries run against db ...
Ghostbird's user avatar
1 vote
0 answers
27 views

Is `{ field: { $in: [null, 'something-1', 'someting-2', []] } }` performance wise okay to use than separate query?

Query 1 : { field: { $in: [null, 'something-1', 'someting-2', []] } } Query 2 : { $or: [ { field: { exists: false } }, { field: { $in: ['something-1', 'something-2'] } }, { ...
Yash Patel's user avatar
0 votes
0 answers
45 views

MongoDB: Filter array field based on entry from the same array

Given the following collection db.playground.insertMany([ { "id": 1, "tags": [{"t": "T1", "v": "t11", "c": 1 }, {"t": &...
Bobby Tables's user avatar
  • 3,003
0 votes
0 answers
24 views

Getting Values in 15 Min Invervalls with MongoDB Aggregatio

I do have a MongoDB collection that stores values from some Airflow sensor. For putting these values into a line chart, I need these values grouped together into 15 minute intervals. My aggregation ...
sucram's user avatar
  • 11
0 votes
0 answers
32 views

Want to extract specific column and fetch count based on the condition

I have below documents in Mongo DB: {_id 666b07c615b7246 host "SERVER1" ip_address "10.0.0.1" status "Running" timestamp 2024-06-13-01-00-10} {_id 666b07c615b7246 host &...
wiTTyMinds Technology's user avatar
0 votes
0 answers
10 views

Saving limited records per TestCase name in Mongodb

I am working on a framework to save test data for QA test cases in mongodb. I want to save only 20 test data per api request. e.g. if api call is for member summary then I want to limit saving only 20 ...
Mainaj Mev's user avatar
0 votes
0 answers
19 views

CSV mongoimiport with merge option not updating existing data

I have an requirement to update existing mongo db document after reading some relevant data from hdfs saved as csv Steps I am taking care of Created a view on mongo collection to convert _id to it ...
Chandra Prakash Yadav's user avatar
0 votes
2 answers
46 views

MongoDB Index for sorting by Date

I have a simple question - maybe too simple so that I don't find an answer: My collection has documents containing a field startTimestamp of type date. The UI shows the documents in descending order ...
Björn Konrad's user avatar
0 votes
1 answer
48 views

MongoDB query with $sort takes too long

I have a large mongo collection, when I run {"$and":[{"fieldCheck":"1"},{"timestamp":{"$lt": MAX_SAFE_INTEGER}}]}, the query results the output fast, ...
Jayant Patil's user avatar

15 30 50 per page
1
2 3 4 5
584