mongodb

Batch insert/update using Mongoid?

I googled and all others, but I didn't find the answer. The question is: Hi, how can I do batch insert with Mongoid to MongoDB? ...

Mongodb and MAMP

I am using MAMP and would like to use mongo with PHP. I am stuck because the version of MAMP I'm using is the latest version I can find, and it's running PHP 5.2.11. The only Mongo PHP install I can find for OSX is for PHP 5.3. Is there any way to get mongo working with PHP using MAMP? ...

Can't access values in MongoDB with cursor using PHP

I seem to be having some trouble using the cursor as I try to pull data out of a MongoDB. Here is a screenshot of my simple data structure: I'm trying to use the following: $collection_name = "users"; $collection = $this->mongo->db->$collection_name; $which_document = array("email" => $email_address); $which_fields = array("words"); ...

Is MongoDB's query or Mongoid's API good for filtering 2000 items from a total of 80,000?

The idea is to do analytics of 30 or 2000 products out of a collection of 80,000 products. Say, if there are 80,000 products, and to get the top products with highest number of pageviews in a category, which can include only 30 or up to 2000 products, so we can either filter out all those products first, and then use map/reduce to find ...

Using MongoDB, any easy way to re-use Map/Reduce results?

For example, when doing Analytics, there can be a map/reduce run that takes 10 seconds. After it is run, if other webpages can make use of that result, then it will be saving 10 seconds per page. It will be good to have the map/reduce result cached somehow. It is possible to record a sucessful map/reduce run as map_reduce_result_[time...

best way to store datetime in to mongodb?

I've seen some using strings, int timestamps and some mongo datetime objects. ...

After MongoDB's Map/Reduce results is saved as a permanent collection, how do you sort it internally, and get it back using Mongoid?

Is it true that Map/Reduce results can be stored permanently, but not sorted? For example, coll = Analytic.collection.map_reduce(map, reduce, :out => 'analyticsCachedResult') the above is stored permanently but is not sorted. To sort it on the fly, it can be coll.find({}, :sort => ['value.pa...

How to tell whether a collection exists in MongoDB using Mongoid?

Since Mongoid.master.collection() returns a collection even if the collection doesn't exist, we can use coll = Mongoid.master.collection('analyticsCachedResult') if coll.count == 0 # [...] end to test if it is an empty collection. Another method is to loop through Mongoid.master.collections.each do |c| return c if c.name == 'ana...

Accessing array in a mongoDB collection

I have a collection as follows: { "_id" : ObjectId("4c9c63a95d765f996ca8dff4"), "count" : "28", "id" : "5565", "person" : [ { "id" : "5435df", "name" : { "fn" : "abc", "ln" : "xyz" }, "sex" : "m", "location" : { "country" : "india" } }, { ...

MongoDB: Updating documents using data from the same document

I have a list of documents, each with lat and lon properties (among others). { 'lat': 1, 'lon': 2, someotherdata [...] } { 'lat': 4, 'lon': 1, someotherdata [...] } [...] I want to modify it so that it looks like this: { 'coords': {'lat': 1, 'lon': 2}, someotherdata [...]} { 'coords': {'lat': 4, 'lon': 1}, someotherdata [...]} [......

MongoDB C# Logging Search Results

Hello! I am working on a mobile site that lets you search for tags of a MongoDB collection of articles. Basically, each article object has a tags property, which stores an array of tag strings. The search works fine, but I also want to add logging to the searches. The reason is that I want to see what visitors are searching for and wh...

Working with hierarchical data in Mongo.

Note: I ended up answering my own question shortly after posting this. Thanks and sorry if you spent time reading my rediculously long post. Introduction I'm sort of a Mongo noob, just trying to get the hang of things here. I am looking at trying to create a hierarchical data structure to which i can add nodes/leaves dynamically. ...

MongoDB using db.things.find("j != 3 && k > 10") vs db.things.find({j: {$ne: 3}, k: {$gt: 10} })

I have been using MongoDB and the Ruby driver and Mongoid, and lines db.things.find({j: {$ne: 3}, k: {$gt: 10} }); just seem so weird and hard to remember. Why not use a parser: db.things.find("j != 3 && k > 10") which can automatically convert to its desired form? (or whatever form it uses internally). ...

Mongoid named scope comparing two time fields in the same document

I need to create a named scope in Mongoid that compares two Time fields within the same document. Such as scope :foo, :where => {:updated_at.gt => :checked_at} This obviously won't work as it treats :checked_at as a symbol, not the actual field. Any suggestions on how this can be done? Update 1 Here is my model where I have this scop...

How to benchmark / test the speed of MySQL, Postgresql, MongoDB, where there are so many cache layers around?

I think with SQLite3, at least it doesn't keep any cached page because there is no server and each write will exit SQLite3, so it can't do any caching directly. But when it is MySQL, Postgresql, or MongoDB, there will be a layer which, when the data is thought to be saved already, it is actually in the memory cache of the DBMS... to be ...

MongoDB for realtime ajax stuff?

Howdie stackoverflow people! So I've been doing some digging regarding these NoSQL databases, MongoDB, CouchDB etc. Though I am still not sure about real time-ish stuff therefore I thought i'd ask around to see if someone have any practical experience. Let's think about web stuff, let's say we've got a very dynamic super ajaxified weba...

Error 1053 When Starting Windows XP Service Running Mongo DB 1.6.3

I'm trying to set up MongoDB 1.6.3 on my Windows XP SP 3 machine. I've followed the instructions from the MongoDB wiki. I can see the Windows service installed but not started. The path to the executable looks like this: "C:\Tools\mongodb-win32-i386-1.6.3\bin\mongod" --bind_ip 127.0.0.1 --logpath c:/mongodb/logs/mongodb.log ...

How do I set up replication from MySQL to MongoDB?

Hi, I have a bunch of data from a scientific experiment stored in a MySQL database, but I want to use MongoDB to take advantage of its map/reduce functionality to power some web charts. What is the best way to have new writes to MySQL replicate into Mongo? Some solution where I inspect the binary MySQL log and update accordingly, just...

Java equivalent of scala query in mongodb

What is the equivalent cde in Java: var result = collectionName.findOne() println(result.get("name").toString) To elaborate, This is my sample db: { "_id" : ObjectId("4ca039f7a5b75ab98a44b149"), "name" : "kaustubh", "country" : "india" } { "_id" : ObjectId("4ca03a85a12344a5e47bcc5c"), "name" : "rahul", "country" : "pakistan" } { "_id...

get most recent name, score

I have a mongodb collection that looks something like this: db.scores.insert({"name": "Bob", value: 96.3, timeStamp:'2010-9-27 9:32:00'}) db.scores.insert({"name": "John", value: 98.3, timeStamp:'2010-9-27 9:28:00'}) db.scores.insert({"name": "Bob", value: 99.3, timeStamp:'2010-9-27 9:29:00'}) db.scores.insert({"name": "John", value: 97...