mongodb

MongoDB or CouchDB or something else?

I know this is another question on this topic but I am a complete beginner in the NoSQL world so I would love some advice. People at SO told me MySQL might be a bad idea for this dataset so I'm asking this. I have lots of data in the following format: TYPE 1 ID1: String String String ... ID2: String String String ... ID3: String String...

Can I search across collections in MongoDB?

I am inserting my data into MongoDB and had 240 such files. Instead of inserting everything into one big collection, I was thinking of inserting the files as a collection by themselves. Is this a good idea if I do a lot of queries on a commonly indexed column? If so, how can I initiate a query to query all the collections in my databas...

How to do ORs in MongoDB?

What's the best way to do a query like this in MongoDB? SELECT * FROM things WHERE (a = 1 or b = 1) and (c = 2 or d = 2) Thanks. ...

Is there any multicore exploiting NoSQL system?

I am playing with MongoDB since yesterday and absolutely love it. I am trying to import lots of data (2 billion rows) and index it but it doesn't seem to be using the 8 cores that my system has adn the import is going at normal rates (60000 records/sec). I can only imagine how long it might take to index two columns in this collection. A...

Sort Sub Documents in MongoDB

Is there a way to sort sub docs in a mongo query? Example(Blog Collection): { "_id" : ObjectId("4c69d19532f73ad544000001"), "content" : "blah blah blah", "comments" : { {"author": "jim", "content":"comment content 1", "date" : "07-24-1995"}, {"author": "joe", "content":"comment content 2", "date" : "07-24-1996"} {"...

Noob PHP/MongoDB Question

I am trying to create a function that checks to see if a user name already exists. I am still trying to get my head wrapped around MongoDB and was wonder what is the best way to approach this? I was going to do some the following (in Code Igniter): $filter = array ('userName' => $value); $exists = $md->find($filter); if ($exist) { ...

Update sub document in MongoDB

Right now I am working on MongoDB in ASP.NET and just gone through an article in which it has taken a blog post example and mentioned the following steps to update comments (sub document). The blog was taken a main document Comments were taken as sub document and posted along with main document When we need to insert a new comment to a...

Limit results of group() in MongoDB

How can I limit the number of results when using group() in MongoDB? Basically I'm looking for the equivalent of this MySQL query: SELECT * FROM items GROUP BY type LIMIT 5; Edit: I just realized this can be done with Map/Reduce, but I read that using Map/Reduce on a single server (my case) is a bit overkill. Is it true? Ultimately, wh...

Ruby on Rails Dynamic Models

I'm working on an application where the end user defines what columns a database table should have based off column names in an Excel spreadsheet that gets uploaded or just by manually defining them before uploading the spreadsheet. Is this something that AR and MySQL could handle or am I better off using mongodb or couchdb? In the tr...

storing a mongoose (node.js orm) query result

Hi, is there anyway to do something like var first_user = User.find({ _id: user_id }).first(); using the mongoose ORM? http://github.com/LearnBoost/mongoose What I'm trying to do is store the returned result of the query for later use. When I use the above all I get returned into the "first_user" var is the QueryWriter object. Ho...

Dates with MongoDB

Possible Duplicate: best way to store datetime in to mongodb? I am curious to know what others are using for storing dates in MongoDB. I need to store dates like user_created, user_lastLogin, ...etc. Has anyone had any experiences in why one approach may be better than another? ...

mongodb replica sets on two physical machines

The two options I can think of for replica sets on two boxes would be as follows: 2 VMs on each machine. 2 mongod instances on each machine. Is either of these better than the other or totally imbecile in comparison to the real solution? This is part of my research for a litte side project: http://bearassbear.blogspot.com/2010/10/i...

MongoDB - how I turn this group() query to map/reduce

I have a collection where each document looks like this {access_key:'xxxxxxxxx', keyword: "banana", count:12, request_hour:"Thu Sep 30 2010 12:00:00 GMT+0000 (UTC)"} {access_key:'yyyyyyyyy', keyword: "apple", count:25, request_hour:"Thu Sep 30 2010 12:00:00 GMT+0000 (UTC)", } ..... To achieve this: SELECT keyword, sum(count) FROM ke...

Using MongoDB in a web environment efficiently

I'm approaching MongoDB from an NHibernate background and I want to know what the best practices are for efficient usage in a web context. With NHibernate, I create a single ISessionFactory for the life of the application, then use an instance of an ISession per request. Take the below code for example (which i hope is typical, please c...

MongoDB Search by property name for any Document with that property

How do I do a search in MongoDB that searches for any documents with a given property? What I want to do is find all the documents that have the property regardless of it's value and I don't seem to be able to do this. I've tried the following db.collection.find({"property", null}); //Finds things that don't have that property db.coll...

mongodb-csharp driver - how to save a property as a reference rather than embedded?

We're doing a little spike on Mongo DB for our C#.NET project to see if it's right for us, and I've run into a little problem with the mongodb-csharp driver by samus that I'm not sure how to implement. Given the following simplified model: public class Campaign { public string Name { get; set; } public IEnumerable<Place...

MongoDB - Indexing embedded keys when the embedded keys are URIs

I'm having a problem getting indexes in MongoDB to work correctly when I'm indexing into embedded documents. The indexes work fine if the inner key is a simple string but because of my data format the inner keys often need to be URIs and this doesn't seem to work, looking at the Mongo log when I try and create the indexes it says the in...

Creating indexes on new collections in MongoDB + PHP

We use MongoDB to collect logs on pageviews. $collection_name = "logs.".date('Y').".".date('m').".".date('d'); $collection = $this->Mongo->$collection_name; $collection->insert($pageview); The code above creates a new collection for every day. I would like to be able to create an index on the above collection when it is created. Is...

Integration tests with MongoDB?

Hi, I need to do several integration tests on a Mongo database using Java, and I was looking for a DbUnit-like solution (DbUnit is for Hibernate) that can populate my database with custom data, and reset the state after each run. Any tips? Thanks ...

Remove inaccessible Mongo shard

I have a MongoDB sharded setup with 3 shards: shard0000, shard0001 and shard0002. The machine that runs shard0002 is down now, which causes all my queries to fail. I'd like to temporarily remove shard0002 from my setup and keep working with the first two shards. That should be doable assuming I only use unsharded collections that reside ...