All Questions
Tagged with mongodb-indexes node.js
19 questions
0
votes
1
answer
44
views
compound index and sort query involving a regex
please read comment and first answer. question is solved.
https://mongoplayground.net/p/J1Hs5RKu39G
I need help interpreting the explain output. I can see that the index is used. However, I am still ...
3
votes
0
answers
59
views
will each condition inside an $or of the $match stage be checked concurrently?
compound index
{
A: 1,
timestamp: 1,
}
and
{
B: 1,
timestamp: 1,
}
db.user.aggregate([
{ $match: {
$or: [ { A: "some_value" }, { B: "some_value" } ]
} },
{
...
-1
votes
1
answer
84
views
will mongodb use index to sort when $or used in $match?
compound index
{
A: 1,
timestamp: 1,
}
and
{
B: 1,
timestamp: 1,
}
db.user.aggregate([
{ $match: {
$or: [ { A: "some_value" }, { B: "some_value" } ]
} },
{
...
-1
votes
2
answers
92
views
mongodb not using index unless field is specified in $match
compound index
{
A: 1,
B: 1
}
In this query, the compound index is not used:
db.user.aggregate([
{ $match: {
B: { $gt: 100 }
} },
{
$sort: {
A: 1
}
},
{
$limit: ...
0
votes
0
answers
123
views
How to dynamically reference mongoDB field names?
Schema of collection:
{
field_1: "number",
field_2: "number",
...
}
I have a query that may reference field_n dynamically depending on certain conditions that are not ...
1
vote
2
answers
279
views
What if some documents don't have a field that is part of an index?
A collection has an indexed involved field_A. But field_A is not required. So what happens if some documents do not have this field? Will the index still work for documents that do have this field?
0
votes
1
answer
365
views
MongoDB indexing not working (1 million records)
Configuration of remote server:
Ubuntu 20.04 on Digital ocean (1vcpu, 1GM Ram, 25GB memory)
MongoDb running on Digital ocean machine
Local machine:
MacOS, Dockerized Nodejs express server (from here I ...
1
vote
0
answers
190
views
At what point does mongoose create indexes in mongoDB?
I am trying to understand when indexes are made in mongodb. I have just learnt that The unique Option is Not a Validator. But I have been using it as a validator in my mongoose schemas for a while now ...
1
vote
1
answer
1k
views
Indexing with Mongoose
I was reading the mongoose docs about indexing and want to find out whether there is a difference between field level indexing and schema level indexing. They mention that "defining indexes at ...
3
votes
8
answers
5k
views
$geoNear requires a 2d or 2dsphere index, but none were found
Add schema.index({startlocation: '2dsphere'}) in schema but not able to clear the error.
schema
tourSchema.index({ startLocation: '2dsphere' }); --> this line is add in model
controller
exports....
2
votes
0
answers
693
views
MongoError: user not allowed to create 2d index
I am creating a program to list nearby objects based on the user's current location.
For this I am using the old [longitude, latitude] system. I will store these coordinates in the location field.
...
0
votes
1
answer
403
views
PM2/NodeJS API with mongoDB index problems [duplicate]
I'm trying to deploy multiple NodeJS rest APIs in the same Ubuntu VPS using PM2, those APIs are used to serve data from different MongoDB database in the same local hosted db server.
I do encounter ...
1
vote
2
answers
192
views
Expires setting in mongoose schema is ignored if index already exists at MongoDB
I'm using the expires field in a mongoose schema in order to set expiration on a given field. For instance:
var Crumbs = new Schema({
...
timestamp: {
type: Date,
expires: 3600,
...
0
votes
0
answers
366
views
Mongoose: Query Nested Properties of a Document With $in
So I am trying to query the following document using $in from Mongoose.
var Reports = [
{
"employee" : {
"gender" : {
"id": 0,
"name" : "Male"...
0
votes
1
answer
107
views
Mongo text index doesn't finish when nothing is returned
I am not sure I have the proper vocabulary to describe the error that I am having so bear with me.
Here is the general schema for the documents in my collection
{
_id: ObjectId(),
name: String,...
17
votes
3
answers
8k
views
Partial indexes in mongodb / mongoose
In the sparse index documentation I found note about mongodb 3.2 partial indexes
Changed in version 3.2: Starting in MongoDB 3.2, MongoDB provides the
option to create partial indexes. Partial ...
25
votes
2
answers
9k
views
Monitoring MongoDB "background operations"?
EDIT:
Basically I'm looking for some hints on how to understand what background operations are running on my MongoDB instance and possibly reduce/disable them when necessary so they don't interfere ...
2
votes
1
answer
1k
views
Unique and Sparse Schema-level Index MongoDB and Mongoose
I am trying to create an index on two fields of a schema that are to be unique and sparse in MongoDB using Mongoose as follows:
var ArraySchema = new Schema ({
user_id: {type: mongoose.Schema....
6
votes
1
answer
4k
views
What is difference between GeoJSON & Legacy coordinate pairs in terms of mongoDb?
I am trying to use $geoNear aggregation operator of mongoDb to calculate distances of users from current location in following way :
'$geoNear': {
near: currentLocation,
distanceField: '...