mongodb,spring-data-mongodb,mongodb-java,mongodb-indexes
You already have an index on that collection with the same name, but with a different definition. My guess is that your current code index is non-unique try: db.Term.getIndexes() If this is indeed the case (you have a non-unique index over code field), issue: db.Term.dropIndex("code_1") (replace with the code field...
mongodb,sharding,mongodb-indexes
First of all, I would caution you not to jump into sharding right away. With your data volume, you should be able to have a single replica set handle your traffic. The real trigger point for sharding is when the working set becomes larger than is reasonable for the RAM...
mongodb,indexing,database-indexes,mongodb-indexes
There are some details about the index selection in the SERVER-3071 JIRA issue but I cannot say if all is still relevant for 3.0. Anyway: MongoDB 3.0.2 seems not consider index interaction for range query. But it will for point intervals: > db.orders.find( { item: {$eq : "abc123"}, qty: {...
Does indexing helps in projection? I believe the only time it will really help (defined by performance etc) is if the query is "covered": http://docs.mongodb.org/manual/tutorial/create-indexes-to-support-queries/ So for example, if you wanted to query on {d:1, e:2} and get back {_id, t, e}, you would do: db.t.ensureIndex({d:1 , e:1, _id:1,...