mongodb

Adding values to an Array in MongoDB with Java

旧城冷巷雨未停 提交于 2021-02-08 07:52:05
问题 I have a document stored in a collection in a mongo database. I want to be able to add to two arrays that are already in the document. Method for creating the document and arrays: public void addNewListName(String listName) { MongoCollection<Document> collection = database.getCollection("lists"); ArrayList< DBObject > array = new ArrayList< DBObject >(); Document list = new Document ("name", listName) .append("terms", array) .append("definitions", array); collection.insertOne(list); } Method

Improving MongoDB Text Search Performance

断了今生、忘了曾经 提交于 2021-02-08 07:50:39
问题 I'm looking for some advice about how improve Text Search performance with MongoDB 2.6. I am also using Mongoose. My mongoose schema has 'body: String' which contains a large chunk of XML. I ran ensureIndex which took a few minutes... db.models.ensureIndex({ body:"text"}) I want to search this text with a user defined string. Model.find({ $text: { $search: searchstr }},function(err,data){ }); While there are only a few thousand documents, the search will often time out ( 2 minutes+). How can

Improving MongoDB Text Search Performance

回眸只為那壹抹淺笑 提交于 2021-02-08 07:49:59
问题 I'm looking for some advice about how improve Text Search performance with MongoDB 2.6. I am also using Mongoose. My mongoose schema has 'body: String' which contains a large chunk of XML. I ran ensureIndex which took a few minutes... db.models.ensureIndex({ body:"text"}) I want to search this text with a user defined string. Model.find({ $text: { $search: searchstr }},function(err,data){ }); While there are only a few thousand documents, the search will often time out ( 2 minutes+). How can

Trouble Starting MongoDB (Mac) - Code: 100

天大地大妈咪最大 提交于 2021-02-08 07:43:51
问题 I installed MongoDB via Homebrew and seem to be having some trouble starting when I run the mongod command. I have tried setting a up the data/db directory correctly and viewed a few other answers on stackoverflow, but haven't been able to figure this out. Here is what I keep getting (sorry I am new to this): 2017-01-02T23:45:53.444-0500 I CONTROL [initandlisten] MongoDB starting : pid=1419 port=27017 dbpath=/data/db 64-bit host=Johns-MacBook-Pro-3.local 2017-01-02T23:45:53.445-0500 I CONTROL

Mongo docker with volume get error

≯℡__Kan透↙ 提交于 2021-02-08 07:27:20
问题 After running docker run --name mongo -p 27017:27017 -v ~/Documents/store/mongo/:/data/db -d mongo --smallfiles [initandlisten] exception in initAndListen: 98 Unable to create/open lock file: /data/db/mongod.lock errno:13 Permission denied Is a mongod instance already running?, terminating In store directory, ls -l drwxr-xr-x 4 MeoBeoI staff 136 Dec 8 17:11 mongo drwxr-xr-x 2 MeoBeoI staff 68 Dec 9 10:20 redis I use OSX 10.11.1 回答1: Looking at the mongo Dockerfile: a user mongodb is created

Mongo docker with volume get error

对着背影说爱祢 提交于 2021-02-08 07:26:20
问题 After running docker run --name mongo -p 27017:27017 -v ~/Documents/store/mongo/:/data/db -d mongo --smallfiles [initandlisten] exception in initAndListen: 98 Unable to create/open lock file: /data/db/mongod.lock errno:13 Permission denied Is a mongod instance already running?, terminating In store directory, ls -l drwxr-xr-x 4 MeoBeoI staff 136 Dec 8 17:11 mongo drwxr-xr-x 2 MeoBeoI staff 68 Dec 9 10:20 redis I use OSX 10.11.1 回答1: Looking at the mongo Dockerfile: a user mongodb is created

how to remove array filed with value null after unset in mongodb

泪湿孤枕 提交于 2021-02-08 06:46:00
问题 I had unset an array field, in mongo but it's leave the field with valué null, the question is, how to remove it! like this image http://i.stack.imgur.com/O2WiV.png 回答1: You could remove all null elements from the array with the $pull operation. See docs Code example: db.collecton.update({condition: "x"}, {$pull: {state: null}}); 来源: https://stackoverflow.com/questions/19445508/how-to-remove-array-filed-with-value-null-after-unset-in-mongodb

how to remove array filed with value null after unset in mongodb

守給你的承諾、 提交于 2021-02-08 06:44:26
问题 I had unset an array field, in mongo but it's leave the field with valué null, the question is, how to remove it! like this image http://i.stack.imgur.com/O2WiV.png 回答1: You could remove all null elements from the array with the $pull operation. See docs Code example: db.collecton.update({condition: "x"}, {$pull: {state: null}}); 来源: https://stackoverflow.com/questions/19445508/how-to-remove-array-filed-with-value-null-after-unset-in-mongodb

Create a mongodb text index with no default language

青春壹個敷衍的年華 提交于 2021-02-08 06:40:00
问题 I'M trying to create a text index without a default language. The official docs specify If you specify a language value of "none", then the text search uses simple tokenization with no list of stop words and no stemming. Hence I tried: createIndex({aliases : "text"}, {name : "aliases_txt"}, {default_language: "none"}) However the created index ignores my option and has "english" as default language: { "v": 1, "key": { "_fts": "text", "_ftsx": 1 }, "name": "aliases_txt", "ns": "ner-dict.ents",

Mongoose Mixed type field with dates

放肆的年华 提交于 2021-02-08 06:39:40
问题 I'm creating an app where a user can create various types of custom fields, and I'd like to store those fields in mongo. The types will include String, Number, and Date. My schema looks like this: const MetaSchema = new mongoose.Schema({ key: String, value: {type: mongoose.Schema.Types.Mixed}, type: String, created_at: {type: Date, default: Date.now} }); This works great, and I can store my data as expected. The issue is, when I want to store a date for instance, that gets sent across to the