MongoDB 2.6 – What's new? – Security



MongoDB 2.6 – What's new? – Security

0 0


mongo-2.6-new-features-presentation

A short presentation for Singapore MUG showing new features in MongoDB 2.6

On Github mcascallares / mongo-2.6-new-features-presentation

MongoDB 2.6

What's new?

Disclaimer

It is work in progress!

Areas of improvement

  • Security
  • Text Search
  • BI / Analytics
  • Operations

Security

Authentication

  • LDAP
  • x509

Authorization

  • User defined roles
  • Field level security

User defined roles

db.createRole( { role: "myClusterWideAdmin", privileges: [], roles: [] } );

db.grantPrivilegesToRole("myClusterWideAdmin", [
	{resource: { cluster : true}, actions : ["addShard"]},
	{resource: { db: "test", collection: ""}, actions : ["enableSharding"]}
 ]);
						

Auditing

  • Admin actions

Text Search

It's GA!!

Integrated within find

db.articles.ensureIndex( { a : "text" } );

db.articles.insert( { a : "the quick brown fox jumped over the lazy dog" } );

db.articles.find( { $text : { $search : "quickly" } } );
						

Integrated within find

# specify language for the search
db.articles.find( { $text : { $search: "quickly", $language : "fr" } } );


# sort results by score
db.articles.find(
	{ $text: { $search: "bake coffee cake" } }, // predicate
	{ score : { $meta : "textScore" } } // projection
).sort( { score: { $meta: "textScore" } } )


# output the score
db.articles.find(
	{ $text:{ $search : "quickly", $language : "fr" } },
	{ score : { $meta : "textScore" } }
);
						

BI / Analytics

Index intersection

db.foo.ensureIndex( { a:1 } );
db.foo.ensureIndex( { b:1 } );

db.foo.find( {a:123, b:456} );
						

Aggregation Framework

  • Returns a cursor
  • Can output to a collection
  • New operators

Aggregation Framework


// using a cursor
db.foo.aggregate( [
	{ $match : { } }, // pipeline
	{ cursor : { batchSize : 1 } }
});

// output to a collection
db.test.aggregate([
	{ $match : { } }, // pipeline
	{ $out : "my_output_collection" } );

// using text search inside the pipeline
db.articles.aggregate( [
	{ $match : { $text : { $search : "chien", $language : "fr" }}}
]);
						

AF - New operators


{ a : 1 } + { $mul : { a : 10 } } -> { a : 10 }

{ a : 1 } + { $min : { a : 100}} -> { a : 1}  // no op

{ $currentDate : { dt : true } } -> {dt: new Date()}

							

Operations

Bulk Writes

db.products.insert([
	{ item: "pencil", qty: 50, type: "no.2" },
	{ item: "pen", qty: 20 },
	{ item: "eraser", qty: 25}
]);

// this change requires wire protocol changes!!!
						

Max time per query


// expensive query with regex without anchor
db.foo.find( { description : /August [0-9]+ 1969/ } ).maxTimeMS(100)

// it works with aggregation framework
db.articles.aggregate( [
	{ $match : { $text : { $search : "chien", $language : "fr" }}}
]).maxTimeMS(100)

						

Bg index on secondaries

Sharding commands

  • mergeChunks
  • cleanupOrphaned

THE END