<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>MongoVUE</title>
	<atom:link href="http://www.mongovue.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.mongovue.com</link>
	<description>Gui tools for MongoDB</description>
	<lastBuildDate>Sun, 01 Apr 2012 04:28:14 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Build MongoDB indexes visually using MongoVUE</title>
		<link>http://www.mongovue.com/2012/03/27/build-mongodb-indexes-visually-using-mongovue/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=build-mongodb-indexes-visually-using-mongovue</link>
		<comments>http://www.mongovue.com/2012/03/27/build-mongodb-indexes-visually-using-mongovue/#comments</comments>
		<pubDate>Tue, 27 Mar 2012 12:15:41 +0000</pubDate>
		<dc:creator>ishaan</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[gui]]></category>
		<category><![CDATA[index]]></category>
		<category><![CDATA[mongoDB]]></category>
		<category><![CDATA[MongoVUE]]></category>

		<guid isPermaLink="false">http://www.mongovue.com/?p=574</guid>
		<description><![CDATA[The concepts of building indexes in MongoDB are very similar to those of relational databases like MySQL, SQL Server etc. You can read about these concepts and theory on this webpage. In this tutorial, we’ll cover how MongoVUE GUI makes it easy to create MongoDB indexes. We’ll refer to the following example used in the [...]]]></description>
			<content:encoded><![CDATA[<p>The concepts of building indexes in MongoDB are very similar to those of relational databases like MySQL, SQL Server etc. You can read about these concepts and theory on <a href="http://www.mongodb.org/display/DOCS/Indexes" target="_blank">this webpage</a>. In this tutorial, we’ll cover how MongoVUE GUI makes it easy to create MongoDB indexes.</p>
<p>We’ll refer to the following example used in the <a href="http://www.mongodb.org/display/DOCS/Indexes" target="_blank">10Gen documentation</a>:</p>
<pre>db.factories.insert( { name: "xyz", metro: { city: "New York", state: "NY" } } );

// alternative A
db.factories.ensureIndex( { metro : 1 } );

// alternative B
db.factories.ensureIndex( { "metro.city" : 1, "metro.state" : 1 } );</pre>
<p>&nbsp;</p>
<h4>Step 1:</h4>
<p>Let’s fire up MongoVUE and navigate to our “infrastructure” database to list “factories” collection</p>
<p><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="image" src="http://www.mongovue.com/wp-content/uploads/2012/03/image_thumb4.png" alt="image" width="781" height="575" border="0" /></p>
<p>&nbsp;</p>
<h4>Step 2:</h4>
<p>Right-click on “factories” collection, and select &#8220;Add Index…” from the context-menu. This will launch the new index window.</p>
<p><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="image" src="http://www.mongovue.com/wp-content/uploads/2012/03/image_thumb5.png" alt="image" width="464" height="368" border="0" /></p>
<p>&nbsp;</p>
<p>Now there are 2 options to build indexes. You can either type the Json under the “Json” tab or you can build it visually as shown in the steps below.</p>
<h4>Step 3:</h4>
<p>Click on the “Visual” tab.</p>
<p><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="http://www.mongovue.com/wp-content/uploads/2012/03/image_thumb6.png" alt="image" width="464" height="368" border="0" /></p>
<p>&nbsp;</p>
<p>Step 4:</p>
<p>Now select the fields on which you want to build the index. In our example, we’ll select “metro”, and select an “Ascending” index on it.</p>
<p><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="http://www.mongovue.com/wp-content/uploads/2012/03/image_thumb7.png" alt="image" width="464" height="368" border="0" /></p>
<p>That’s it. Hit “Create” button and you are done.</p>
<p>You can also choose to expand “metro” key into its sub-keys, and use those to build the index (see below):</p>
<p><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border: 0px;" title="image" src="http://www.mongovue.com/wp-content/uploads/2012/03/image_thumb8.png" alt="image" width="464" height="382" border="0" /></p>
<p>Again, simply hit the “Create” button and you are done!</p>
<p>Things to note:</p>
<ul>
<li>MongoVUE does not scan each and every document in your collection to show an aggregated document under “Visual” tab. It scans the first 5 documents only.</li>
<li>If these first 5 documents do not contain all the fields then you may index some fields under “Visual” tab and then manually switch to “Json” tab to add the additional ones before hitting “Create” button</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.mongovue.com/2012/03/27/build-mongodb-indexes-visually-using-mongovue/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Establishing connections to servers and replica-sets using MongoVUE</title>
		<link>http://www.mongovue.com/2012/03/26/establishing-connections-to-servers-and-replica-sets-using-mongovue/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=establishing-connections-to-servers-and-replica-sets-using-mongovue</link>
		<comments>http://www.mongovue.com/2012/03/26/establishing-connections-to-servers-and-replica-sets-using-mongovue/#comments</comments>
		<pubDate>Mon, 26 Mar 2012 11:30:53 +0000</pubDate>
		<dc:creator>ishaan</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[connections]]></category>
		<category><![CDATA[mongoDB]]></category>
		<category><![CDATA[MongoVUE]]></category>
		<category><![CDATA[primary]]></category>
		<category><![CDATA[replica-set]]></category>
		<category><![CDATA[slave-ok]]></category>

		<guid isPermaLink="false">http://www.mongovue.com/?p=557</guid>
		<description><![CDATA[MongoVUE connection manager makes it easy to create and store connections to your MongoDB servers. Establishing a new connection is simple &#8211; click on the add icon, you&#8217;ll get a blank screen as shown below: Step 1 &#160; Step 2: Now simply add in the values as indicated below Name – a name you want [...]]]></description>
			<content:encoded><![CDATA[<p>MongoVUE connection manager makes it easy to create and store connections to your MongoDB servers. Establishing a new connection is simple &#8211; click on the add icon, you&#8217;ll get a blank screen as shown below:</p>
<h4>Step 1</h4>
<p><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="image" src="http://www.mongovue.com/wp-content/uploads/2012/03/image_thumb.png" alt="image" width="340" height="390" border="0" /></p>
<p>&nbsp;</p>
<h4>Step 2:</h4>
<p>Now simply add in the values as indicated below</p>
<p><strong>Name</strong> – a name you want to give to this connection for easy mental recall</p>
<p><strong>Server</strong> – IP address of your server or DNS name</p>
<p><strong>Port</strong> – the port on which MongoDB server is listening</p>
<p><strong>Username </strong>(optional) – username if you are using authentication</p>
<p><strong>Password</strong> (optional) – password</p>
<p><strong>Database </strong>(optional) – comma separated list of databases, if you want to connect to specific dbs. if you leave this empty then all databases will be available under “Database Explorer”</p>
<p><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="image" src="http://www.mongovue.com/wp-content/uploads/2012/03/image_thumb1.png" alt="image" width="340" height="390" border="0" /></p>
<p><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="image" src="http://www.mongovue.com/wp-content/uploads/2012/03/image_thumb2.png" alt="image" width="340" height="390" border="0" /></p>
<p>That&#8217;s it, hit the “Save”, and double click on your connection name to open it.</p>
<p>&nbsp;</p>
<h4>Step 2(b)</h4>
<p>Lets us now explore how to connect to replica sets. Let us assume that we have 4 servers in our set:</p>
<p>Server 1: a.replica-set.com  Port: 28001</p>
<p>Server 2: b.replica-set.com  Port: 28002</p>
<p>Server 3: c.replica-set.com  Port: 28003</p>
<p>Server 4: d.replica-set.com  Port: 28004</p>
<p>There is no place in the connection window to enter information on these 4 servers. Some replica sets may have more servers also. So, the trick is to enter the information on all these server on in the “Server:” text box. See image below:</p>
<p><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="image" src="http://www.mongovue.com/wp-content/uploads/2012/03/image_thumb3.png" alt="image" width="340" height="390" border="0" /></p>
<p>The syntax to enter these servers is a comma separated list of server and its port configuration:</p>
<pre>a.replica-set.com:28001, b.replica-set.com:28002, c.replica-set.com:28003, d.replica-set.com:28004</pre>
<p>Please note that the syntax above, port number is optional. So if you are using default ports then you may simply skip port info:</p>
<pre>a.replica-set.com, b.replica-set.com, c.replica-set.com, d.replica-set.com</pre>
<p>You must have noticed in the screenshot above that the “Port:” textbox is replaced by a “ConnectTo:” dropdown. When you connect to a replica set, you can provide additional information on which specific server(s) you want to connect to. The options in this dropdown are:</p>
<p><strong>All</strong> &#8211; Wait for all members of the replica set to be connected.</p>
<p><strong>Primary</strong> &#8211; Wait for the primary member of the replica set to be connected.</p>
<p><strong>AnySlaveOk</strong> &#8211; Wait for any slaveOk member of the replica set to be connected (includes primary, secondaries and passives).</p>
<p>You can read more about these options at <a href="http://api.mongodb.org/csharp/1.2/html/1cc47f9a-a940-7242-4db0-6354b28c87ba.htm" target="_blank">this url</a>.</p>
<p>That&#8217;s it, hit the “Save”, and double click on your connection name to open it.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mongovue.com/2012/03/26/establishing-connections-to-servers-and-replica-sets-using-mongovue/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Connecting to a remote server over SSH</title>
		<link>http://www.mongovue.com/2011/08/04/mongovue-connection-to-remote-server-over-ssh/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=mongovue-connection-to-remote-server-over-ssh</link>
		<comments>http://www.mongovue.com/2011/08/04/mongovue-connection-to-remote-server-over-ssh/#comments</comments>
		<pubDate>Thu, 04 Aug 2011 16:35:55 +0000</pubDate>
		<dc:creator>ishaan</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[MongoVUE]]></category>
		<category><![CDATA[PuTTY]]></category>
		<category><![CDATA[SSH]]></category>
		<category><![CDATA[Tunnel]]></category>

		<guid isPermaLink="false">http://www.mongovue.com/2011/08/04/mongovue-connection-to-remote-server-over-ssh/</guid>
		<description><![CDATA[Many users have their MongoDB instance running on a remove server (say in AWS or some other cloud) and for security reasons all/most of the ports on this server are purposely blocked including port number 27017 (which is the default one for MongoDB). Now MongoVUE doesn&#8217;t natively support SSH protocol. So you cannot directly connect [...]]]></description>
			<content:encoded><![CDATA[<p>Many users have their MongoDB instance running on a remove server (say in AWS or some other cloud) and for security reasons all/most of the ports on this server are purposely blocked including port number 27017 (which is the default one for MongoDB). </p>
<p>Now MongoVUE doesn&#8217;t natively support SSH protocol. So you cannot directly connect to these servers over SSH. Also, there are no SSH options in MongoVUE connections dialog!    <br /><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="mongovue-cannot-ssh-to-server" border="0" alt="mongovue-cannot-ssh-to-server" src="http://new.mongovue.com/wp-content/uploads/2011/08/mongovue-cannot-ssh-to-server.png" width="606" height="169" /></p>
<p>But there is some good news too. It is fairly easy to setup an SSH tunnel between your PC (client) and your server, and MongoVUE can use this tunnel to connect to your remotely running MongoDB instance.</p>
<p><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="mongovue-use-ssh-tunnel-on-putty" border="0" alt="mongovue-use-ssh-tunnel-on-putty" src="http://new.mongovue.com/wp-content/uploads/2011/08/mongovue-use-ssh-tunnel-on-putty.png" width="606" height="176" /></p>
<p>Let us do this stepwise.    </p>
<h3>Step 1</h3>
<p>Download and install <a href="http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html">PuTTY</a>. This software will be used to setup SSH tunnel.</p>
<p>&#160;</p>
<h3>Step 2</h3>
<p>Launch PuTTY, and navigate to the “Connection &gt; SSH &gt; Tunnels” screen</p>
<p><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="PuTTY SSH Tunnel screen" border="0" alt="PuTTY SSH Tunnel screen" src="http://new.mongovue.com/wp-content/uploads/2011/08/image.png" width="458" height="440" /></p>
<p>&#160;</p>
<h3>Step 2</h3>
<p>For “Source port”, enter the port number you want to utilize on your client PC. We’ll use “5151”.</p>
<p>For “Destination”, enter the IP and port on the remove server to which you wan to connect to. Here we’ll use “127.0.0.1:27017”.</p>
<p>Select the “IPv4” radio button</p>
<p><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="Configure local port and destination info" border="0" alt="Configure local port and destination info" src="http://new.mongovue.com/wp-content/uploads/2011/08/image1.png" width="458" height="440" /></p>
<p>&#160;</p>
<h3>Step 3</h3>
<p>Click the “Add” button</p>
<p><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="Click the &quot;Add&quot; button" border="0" alt="Click the &quot;Add&quot; button" src="http://new.mongovue.com/wp-content/uploads/2011/08/image2.png" width="458" height="440" /></p>
<p>&#160;</p>
<h3>Step 4</h3>
<p>Now click the “Session” category on the left, and enter IP of your remote server under “Host Name”.</p>
<p><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="Enter remove server IP" border="0" alt="Enter remove server IP" src="http://new.mongovue.com/wp-content/uploads/2011/08/image3.png" width="458" height="440" /></p>
<p>&#160;</p>
<h3>Step 5</h3>
<p>Click the “Open” button. You will be asked to enter your user and password info on the shell. Once you login, your SSH tunnel is setup!</p>
<p>&#160;</p>
<h3>Step 6</h3>
<p>We are almost done. Lets fire up MongoVUE and open a new connection windows. On this windows, the server and port number we enter are for PC client end of SSH tunnel. Now if our MongoDB needs some authentication, we can enter that in Username and Password fields.</p>
<p>&#160;</p>
<p><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="Enter your port number plus auth info" border="0" alt="Enter your port number plus auth info" src="http://new.mongovue.com/wp-content/uploads/2011/08/image4.png" width="357" height="338" /></p>
<p>&#160;</p>
<p>Hit the “Save” button and then open the connection!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mongovue.com/2011/08/04/mongovue-connection-to-remote-server-over-ssh/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>MongoVUE version 1.3.0 released</title>
		<link>http://www.mongovue.com/2011/07/26/mongovue-version-1-3-0-released/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=mongovue-version-1-3-0-released</link>
		<comments>http://www.mongovue.com/2011/07/26/mongovue-version-1-3-0-released/#comments</comments>
		<pubDate>Tue, 26 Jul 2011 09:49:27 +0000</pubDate>
		<dc:creator>ishaan</dc:creator>
				<category><![CDATA[Releases]]></category>
		<category><![CDATA[release]]></category>

		<guid isPermaLink="false">http://www.mongovue.com/2011/07/26/mongovue-version-1-3-0-released/</guid>
		<description><![CDATA[Features and upgrades include: Inline editing Users can edit values in TreeView directly by double clicking on a cell. (Note: The new value must be of the same type as the existing value. Direct editing of Arrays, Documents and Binary values is not yet supported) Find View A new &#8216;Find&#8217; view has been introduced. The [...]]]></description>
			<content:encoded><![CDATA[<p>Features and upgrades include:</p>
<ul>
<li>Inline editing
<ul>
<li>Users can edit values in TreeView directly by double clicking on a cell. (Note: The new value must be of the same type as the existing value. Direct editing of Arrays, Documents and Binary values is not yet supported) </li>
</ul>
</li>
<li>Find View
<ul>
<li>A new &#8216;Find&#8217; view has been introduced. The old view has been deprecated to &#8216;Find 2&#8242; </li>
<li>Both these views run in the background, so gui stays responsive </li>
</ul>
</li>
<li>TreeView
<ul>
<li>For binary data, the subtype is now displayed in 3rd column (&#8216;Type&#8217;) </li>
<li>Right click menu has 2 new items &#8216;Copy&#8217; and &#8216;Copy Json&#8217; </li>
<li>BUG FIX: &#8216;Send To&#8217; shortcut initializes the new view with entire document (formatted json code) </li>
</ul>
</li>
<li>MapReduce View
<ul>
<li>Execution runs in the background, so gui stays responsive </li>
<li>New toolbar introduced on top </li>
</ul>
</li>
<li>Data Import from RDBMS
<ul>
<li>Postgres db is now supported (paid version only) </li>
<li>New ‘Selet All’ checkbox added as a shortcut to select/de-select all tables </li>
<li>BUG FIX: Multiple bugs fixed in importing data from MySQL (application freeze) </li>
</ul>
</li>
<li>Underlying text editor used in many views upgraded to be faster, snappier </li>
<li>Database names can contain &#8216;-&#8217; </li>
<li>Input window that creates new db/collection now accepts &#8216;Esc&#8217; and &#8216;Enter&#8217; keys </li>
<li>BUG FIX &#8211; Using admin db username/password now correctly authenticates with all dbs </li>
<li>Code refactored (major) </li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.mongovue.com/2011/07/26/mongovue-version-1-3-0-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to perform MapReduce operations in MongoVUE</title>
		<link>http://www.mongovue.com/2011/04/05/how-to-perform-mapreduce-operations-in-mongovue-a-step-by-step-guide/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=how-to-perform-mapreduce-operations-in-mongovue-a-step-by-step-guide</link>
		<comments>http://www.mongovue.com/2011/04/05/how-to-perform-mapreduce-operations-in-mongovue-a-step-by-step-guide/#comments</comments>
		<pubDate>Tue, 05 Apr 2011 16:46:45 +0000</pubDate>
		<dc:creator>ishaan</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[MapReduce]]></category>
		<category><![CDATA[MongoVUE]]></category>

		<guid isPermaLink="false">http://www.mongovue.com/2011/04/05/how-to-perform-mapreduce-operations-in-mongovue-a-step-by-step-guide/</guid>
		<description><![CDATA[This post will detail the steps (and corresponding screens) in MongoVUE for solving the MapReduce problem defined in an earlier tutorial – Yet another MongoDB MapReduce tutorial (should be read before reading the present tutorial). Step 1 Open MongoVUE and connect to the server that contains the collection “cities” &#160; &#160; Step 2 Right-click on [...]]]></description>
			<content:encoded><![CDATA[<p>This post will detail the steps (and corresponding screens) in MongoVUE for solving the MapReduce problem defined in an earlier tutorial – <a href="http://www.mongovue.com/2010/11/03/yet-another-mongodb-map-reduce-tutorial/">Yet another MongoDB MapReduce tutorial</a> (should be read before reading the present tutorial).</p>
<h4>Step 1</h4>
<p>Open MongoVUE and connect to the server that contains the collection “cities”</p>
<p><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Connect to MongoDB" border="0" alt="Connect to MongoDB" src="http://new.mongovue.com/wp-content/uploads/2011/04/image7.png" width="827" height="645" />&#160; </p>
<p>&#160;</p>
<h4>Step 2</h4>
<p>Right-click on “cities” collection under “Database Explorer”, and select “MapReduce”. This will launch the MapReduce view. </p>
<p><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Launch the MapReduce view" border="0" alt="Launch the MapReduce view" src="http://new.mongovue.com/wp-content/uploads/2011/04/image8.png" width="827" height="645" /> </p>
<p>&#160;</p>
<h4>Step 3</h4>
<p>Write the JavaScript code for Map function in “Map” tab.</p>
<p><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Write Map code" border="0" alt="Write Map code" src="http://new.mongovue.com/wp-content/uploads/2011/04/image9.png" width="827" height="645" /> </p>
<p>&#160;</p>
<h4>Step 4</h4>
<p>Go to “Reduce” tab and enter your JavaScript Reduce code.</p>
<p><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Write Reduce code" border="0" alt="Write Reduce code" src="http://new.mongovue.com/wp-content/uploads/2011/04/image10.png" width="827" height="645" /> </p>
<p>&#160;</p>
<h4>Step 5</h4>
<p>Go to “Finalize” tab and enter your JavaScript Finalize code.</p>
<p><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Write Finalize code" border="0" alt="Write Finalize code" src="http://new.mongovue.com/wp-content/uploads/2011/04/image11.png" width="827" height="645" /> </p>
<p>&#160;</p>
<h4>Step 6</h4>
<p>Go to “In &amp; Out” tab. Enter the Json code under “{Query}” to exclude cities from USA.</p>
<p><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Enter Input options under {Query}" border="0" alt="Enter Input options under {Query}" src="http://new.mongovue.com/wp-content/uploads/2011/04/image12.png" width="827" height="645" /> </p>
<p>&#160;</p>
<h4>Step 7</h4>
<p>We are almost done, but before we run this program, let’s just save it to disk first. Click on the small arrow next to “Go!” button and select “Save As”. You will be prompted for a filename. Enter a suitable name, and your MapReduce code will be saved to a corresponding “.vumr” file on your computer.</p>
<p><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://new.mongovue.com/wp-content/uploads/2011/04/image13.png" width="230" height="155" /> </p>
<p>&#160;</p>
<h4>Step 8</h4>
<p>We are ready to roll. Just click the “Go!” button, and that’ll start the MapReduce operation. At the end, you’ll see the results in the bottom pane. You can also check the time taken in the statusbar. Additionally, the shell command is also available under “Learn Shell” toolbox.</p>
</p>
<p><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="MapReduce is done" border="0" alt="MapReduce is done" src="http://new.mongovue.com/wp-content/uploads/2011/04/image14.png" width="827" height="645" /></p>
<p>&#160;</p>
<p>This completes our tutorial. You can check the Learn Shell toolbox, it displays the following command.</p>
<p>&#160;</p>
<pre>db.runCommand({ mapreduce: cities,
 map : function Map() {
	var key = this.CountryID;
	emit(key, {
		&quot;data&quot;:
		[
			{
				&quot;name&quot; : this.City,
				&quot;lat&quot;  : this.Latitude,
				&quot;lon&quot;  : this.Longitude
			}
		]
	});
}
 reduce : function Reduce(key, values) {

	var reduced = {&quot;data&quot;:[]};
	for (var i in values) {
		var inter = values[i];
		for (var j in inter.data) {
			reduced.data.push(inter.data[j]);
		}
	}

	return reduced;
}

 finalize : function Finalize(key, reduced) {

	if (reduced.data.length == 1) {
		return { &quot;message&quot; : &quot;This Country contains only 1 City&quot; };
	}

	var min_dist = 999999999999;
	var city1 = { &quot;name&quot;: &quot;&quot; };
	var city2 = { &quot;name&quot;: &quot;&quot; };

	var c1;
	var c2;
	var d;
	for (var i in reduced.data) {
		for (var j in reduced.data) {
			if (i&gt;=j) continue;
			c1 = reduced.data[i];
			c2 = reduced.data[j];
			d = Math.sqrt((c1.lat-c2.lat)*(c1.lat-c2.lat)+(c1.lon-c2.lon)*(c1.lon-c2.lon));
			if (d &lt; min_dist &amp;&amp; d &gt; 0) {
				min_dist = d;
				city1 = c1;
				city2 = c2;
			}
		}
	}

	return {&quot;city1&quot;: city1.name, &quot;city2&quot;: city2.name, &quot;dist&quot;: min_dist};
}
 query : { &quot;CountryID&quot; : { &quot;$ne&quot; : 254 } }
 out : { inline : 1 }
 });</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.mongovue.com/2011/04/05/how-to-perform-mapreduce-operations-in-mongovue-a-step-by-step-guide/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Viewing hierarchical data in Table View</title>
		<link>http://www.mongovue.com/2010/12/06/viewing-hierarchical-data-in-table-view/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=viewing-hierarchical-data-in-table-view</link>
		<comments>http://www.mongovue.com/2010/12/06/viewing-hierarchical-data-in-table-view/#comments</comments>
		<pubDate>Mon, 06 Dec 2010 06:26:31 +0000</pubDate>
		<dc:creator>ishaan</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[MongoVUE]]></category>

		<guid isPermaLink="false">http://blog.mongovue.com/2010/12/06/viewing-hierarchical-data-in-table-view/</guid>
		<description><![CDATA[MongoVUE provides 3 different views of data – TreeView, TableView and TextView. The TableView provides a simplified representation of hierarchical data in 2 dimensions (akin to tables in relational databases). Some new improvements have been added in version 0.9.0 and these are discussed below. Like always, let’s explore these enhancements with an example. We’ll take [...]]]></description>
			<content:encoded><![CDATA[<p>MongoVUE provides 3 different views of data – TreeView, TableView and TextView. The TableView provides a simplified representation of hierarchical data in 2 dimensions (akin to tables in relational databases). Some new improvements have been added in version 0.9.0 and these are discussed below.</p>
<p>Like always, let’s explore these enhancements with an example. We’ll take a collection named “countryInfo” which contains information on all countries. Each document in “countryInfo” looks like this:</p>
<pre>{
  &quot;_id&quot;: &quot;Albania&quot;,
  &quot;value&quot;: {
    &quot;Capital&quot;: &quot;Tirana &quot;,
    &quot;Currency&quot;: &quot;Lek &quot;,
    &quot;Population&quot;: 3510484
  }
}</pre>
<p>In other words, each document’s _id field is the unique Country name and the value key contains a sub-document with important information. </p>
<p>The TreeView (expanded for Albania) is shown below.<br />
  <br /><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="TreeView" border="0" alt="TreeView" src="http://new.mongovue.com/wp-content/uploads/2010/12/image.png" width="617" height="527" /> </p>
<p>&#160;</p>
<p>If you go to TableView, you’ll notice a new bar/widget at the top displaying quick information on number of documents.&#160; </p>
<p><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="New additions to MongoVUE TableView" border="0" alt="New additions to MongoVUE TableView" src="http://new.mongovue.com/wp-content/uploads/2010/12/image1.png" width="617" height="527" /> </p>
<p>You’ll also notice that if the cell data is a document then a small green colored arrow (pointing to right) is shown in the cell. This green arrow simply means that there is more information available in this cell and to get it, you simply have to double-click on that cell. So let’s double-click in the cell for Albania to dig in.</p>
<p>&#160;</p>
<p><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="MongoVUE displaying hierarchical data" border="0" alt="MongoVUE displaying hierarchical data" src="http://new.mongovue.com/wp-content/uploads/2010/12/image2.png" width="617" height="527" /> </p>
<p>You can see that the bar at top now displays your trail (breadcrumbs): “100 Documents &gt;&gt; 1 &gt;&gt; value”. This tells you that out of 100 available documents, you chose the 2nd document (1st is index 0), then you are looking at its “value” key. You can click on any of these crumbs in the trail to go back. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.mongovue.com/2010/12/06/viewing-hierarchical-data-in-table-view/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Exporting data from MongoDB</title>
		<link>http://www.mongovue.com/2010/11/19/exporting-data-from-mongodb/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=exporting-data-from-mongodb</link>
		<comments>http://www.mongovue.com/2010/11/19/exporting-data-from-mongodb/#comments</comments>
		<pubDate>Fri, 19 Nov 2010 05:58:23 +0000</pubDate>
		<dc:creator>ishaan</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Export]]></category>
		<category><![CDATA[mongoDB]]></category>
		<category><![CDATA[MongoVUE]]></category>

		<guid isPermaLink="false">http://blog.mongovue.com/2010/11/19/exporting-data-from-mongodb/</guid>
		<description><![CDATA[While working with MongoDB you’ll often run into situations where you need to get data out of your server. MongoVUE has some built-in exporting capabilities that make it fairly simple to fetch data in CSV and Microsoft Excel formats. Let’s explore this feature in detail. Data can be exported from “View” and “Find” options through [...]]]></description>
			<content:encoded><![CDATA[<p>While working with MongoDB you’ll often run into situations where you need to get data out of your server. MongoVUE has some built-in exporting capabilities that make it fairly simple to fetch data in CSV and Microsoft Excel formats. Let’s explore this feature in detail.</p>
<p>Data can be exported from “View” and “Find” options through the “Refresh&quot; dropdown and “More” dropdown respectively, as displayed below.</p>
<p><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="Exporting MongoDB data through View option" border="0" alt="Exporting MongoDB data through View option" src="http://new.mongovue.com/wp-content/uploads/2010/11/image7.png" width="575" height="154" /> </p>
<p><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="Exporting MongoDB data through Find option" border="0" alt="Exporting MongoDB data through Find option" src="http://new.mongovue.com/wp-content/uploads/2010/11/image8.png" width="601" height="260" /> </p>
<p>&#160;</p>
<p>Upon clicking the Export menu, you’ll get a popup window as shown below. The combo-box at the top allows you to select the format in which you want to export the data. Currently following 3 formats are available:</p>
<ul>
<li>CSV or Comma Separated Values</li>
<li>TSV or Tab Separated Values</li>
<li>MS Excel format</li>
</ul>
<p><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="Export Documents from MongoDB" border="0" alt="Export Documents from MongoDB" src="http://new.mongovue.com/wp-content/uploads/2010/11/image9.png" width="347" height="388" /> </p>
<p>Each format displays a number of settings (fairly obvious) that allow you to fine-tune the data exported. Majority of times, these setting should work as is, without any modifications.</p>
<p>&#160;</p>
<p>Now lets get to the last step – MongoVUE gives you 3 buttons for exporting your data.</p>
<ul>
<li><strong>Clipboard</strong>: When you click on this button, the selected data is copied to clipboard. You can now go to a suitable application and “Paste”/Ctrl+V to get this data.</li>
<li><strong>Instance</strong>: Launches the notepad (or the correct application) and with the selected data in it.</li>
<li><strong>File</strong>: Opens a “File Save As” dialog, allowing you to save the selected data to a file on your disk.</li>
</ul>
<p>&#160;</p>
<p>Please note that support for other export formats (like Json and Xml) are on the roadmap and will be added in future.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mongovue.com/2010/11/19/exporting-data-from-mongodb/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Yet another MongoDB Map Reduce tutorial</title>
		<link>http://www.mongovue.com/2010/11/03/yet-another-mongodb-map-reduce-tutorial/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=yet-another-mongodb-map-reduce-tutorial</link>
		<comments>http://www.mongovue.com/2010/11/03/yet-another-mongodb-map-reduce-tutorial/#comments</comments>
		<pubDate>Wed, 03 Nov 2010 14:08:36 +0000</pubDate>
		<dc:creator>ishaan</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[MapReduce]]></category>
		<category><![CDATA[mongoDB]]></category>
		<category><![CDATA[MongoVUE]]></category>

		<guid isPermaLink="false">http://blog.mongovue.com/2010/11/03/yet-another-mongodb-map-reduce-tutorial/</guid>
		<description><![CDATA[Background As the title says, this is yet-another-tutorial on Map Reduce using MongoDB. But two things that are different here: A problem solving approach is used, so we’ll take a problem, solve it in SQL first and then discuss Map Reduce. Lots of diagrams, so you’ll hopefully better understand how Map Reduce works. &#160; The [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Background</strong></p>
<p>As the title says, this is yet-another-tutorial on Map Reduce using MongoDB. But two things that are different here:</p>
<ol>
<li>A problem solving approach is used, so we’ll take a problem, solve it in SQL first and then discuss Map Reduce. </li>
<li>Lots of diagrams, so you’ll hopefully better understand how Map Reduce works. </li>
</ol>
<p>&#160;</p>
<p><strong>The Problem</strong></p>
<p>So without further ado, let us get started. We’ll use the GeoBytes’ free GeoWorldMap database. It is a database of countries, their states/regions and major cities. You can find this database on <a href="http://geobytes.com/" target="_blank">this page</a> under Geobytes’ Free Services section. The zip archive contains CSV files and <a href="http://epicenter.geobytes.com/MySqlInstructions.htm" target="_blank">instructions on importing this data to MySQL are available here</a>.</p>
<p>The task is to find the 2 closest cities in each country, except in United States. (I excluded USA because over 75% of the cities in “cities” table are from USA, and by excluding it the results arrive much faster! Plus, it gives an additional flavor to the task.)</p>
<table border="0" cellspacing="0" cellpadding="2" width="250">
<tbody>
<tr>
<td valign="top" width="250"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="title" border="0" alt="alt" src="http://new.mongovue.com/wp-content/uploads/2010/11/image.png" width="206" height="293" fields?="fields?" table="table" cities?="cities?" /></td>
</tr>
<tr>
<td valign="top" width="250">This image on top displays field and corresponding datatypes of “cities” table. Note the fields CountryID, Latitude and Longitude.</td>
</tr>
</tbody>
</table>
<p>&#160;</p>
<p><strong>Assumptions</strong></p>
<p>For sake of simplicity, we’ll represent earth as a 2D plane. The distance between any two points P1 (x1,y1) and P2 (x2,y2) on a 2D plane is computed as Square-Root of { (x1-x2)<sup>2</sup> + (y1-y2)<sup>2 </sup>}</p>
<p>&#160;</p>
<h2>SQL Solution</h2>
<p>If the distance between each pair of cities in a country were known then we could simply apply a GROUP BY statement where we divide the data by Country and find those two cities where the distance is minimum. Since data is not available in this form, let’s try to manipulate it to get the desired structure.</p>
<pre>/* QUERY1 - VIEW: city_dist */
create view city_dist as
select c1.CountryID,
	c1.CityId, c1.City,
	c2.CityId as CityId2, c2.City as City2,
	sqrt(pow(c1.Latitude-c2.Latitude,2) + pow(c1.Longitude-c2.Longitude,2)) as Dist
from cities c1 inner join cities c2
where c1.CountryID = c2.CountryID /* Country should be same */
and c1.CityId &lt; c2.CityId  /* Calculate distance between 2 cities only once */
and c1.CountryID &lt;&gt; 254 /* Don't include US cities */; </pre>
<p>&#160;</p>
<p>Now that we have distance between each pair of cities, we can now group this data by country and then proceed to select those 2 cities that have the least value for “Dist” field but still greater than zero. This can be accomplished easily as shown below:</p>
<p>&#160;</p>
<pre>/* QUERY 2 */
select city_dist.*
from (
	select CountryID, min(Dist) as MinDist
	from city_dist
	where Dist &gt; 0 /* Avoid cities which share Latitude &amp; Longitude */
	group by CountryID
) a inner join city_dist on a.CountryID = city_dist.CountryID and a.MinDist = city_dist.Dist;</pre>
<p>&#160;</p>
<p>That completes our SQL solution to the given problem. (You can delete the View “city_dist” later)</p>
<p>It is important to note the steps we followed. In the first step we performed all the computations (by calculating the distance between 2 cities of each country). In the next step we grouped (or divided) our results by country and selected those 2 cities where the value of distance was least. These steps can be represented graphically as shown below.</p>
<p><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="SQL 2 step solution" border="0" alt="SQL 2 step solution" src="http://new.mongovue.com/wp-content/uploads/2010/11/image1.png" width="614" height="277" /></p>
<p>&#160;</p>
<p>&#160;</p>
<h2>Map Reduce Solution</h2>
<p>We can easily import our “cities” table from MySQL to MongoDB using MongoVUE. Instruction on importing are <a href="http://www.mongovue.com/2010/07/30/import-data-from-mysql/">available here</a>. Once this is done, a sample document in MongoDB looks like this:</p>
<p><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Sample document in &quot;cities&quot; collection" border="0" alt="Sample document in &quot;cities&quot; collection" src="http://new.mongovue.com/wp-content/uploads/2010/11/image2.png" width="313" height="247" /></p>
<p>&#160;</p>
<p>Map Reduce is a 3 step approach to solving problems.</p>
<p><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Map Reduce 2 step approach" border="0" alt="Map Reduce 2 step approach" src="http://new.mongovue.com/wp-content/uploads/2010/11/image3.png" width="765" height="272" /></p>
<p>&#160;</p>
<p><strong>Step 1 – Map</strong></p>
<p>Map step is used to group or divide data into sets based on a desired value (called Key). This is actually similar to Step 2 of SQL solution above. The Map step is accomplished by writing a JavaScript function, and the signature of this function is given below.</p>
<pre>function /*void*/ MapCode() {

}</pre>
<p>&#160;</p>
<p>In other words the Map function takes no arguments and returns no data! That doesn’t seem much useful, does it? So lets explore it in greater detail.&#160; Although Map function doesn’t take any arguments, it gets invoked on each document of the collection as a method. Since it is invoked as a method, it has access to “this” reference. So with “this” you can access any data within the “current” document. Something else that is available is the “emit” function and it takes two 2 arguments, first, the key on which you want to group the data. Second argument is the data itself that you want to group.</p>
<p>When we write the Map function, we need to be careful about 3 things.</p>
<ol>
<li>Firstly, how do we want to divide or group the data? In other words, what is our key? Or what should be passed as the first parameter to “emit” function? </li>
<li>Secondly, what part of the data will we we need or what part of data is extraneous? This helps un in determining the second parameter passed to “emit” function. </li>
<li>Thirdly, in what form or structure do we need our data? This helps us refine the second parameter of “emit” function. </li>
</ol>
<p>Let’s find the answers to these questions.</p>
<ol>
<li>It should be quite evident that we will group our data based on “CountryID”. We used the same field in SQL too. So we’ll pass “CountryID” as the first parameter to “emit” function. </li>
</ol>
<p>&#160;</p>
<pre>function MapCode() {
	emit(this.CountryID, ...);
}</pre>
<p>&#160;</p>
<p>We certainly don’t care about RegionID, TimeZone, DmaID, County and Code for calculating closest cities. We can easily ignore these. Keys that seems helpful are CityId, City, Latitude and Longitude.</p>
<p>&#160;</p>
<pre>function MapCode() {
	emit(this.CountryID,
	{
		&quot;city&quot;: this.City,
		&quot;lat&quot;:  this.Latitude,
		&quot;lon&quot;:  this.Longitude
	});
}</pre>
<p>&#160;</p>
<p>With this we have answered our second question as well, i.e. what data is extraneous and what is necessary. Now before we get to the third question above, lets understand a bit more about Reduce. After the Map step completes we obtains a bunch of key-value pairs. In our case, we’ll get a bunch of key-value pairs (where key is CountryID and value is a Json object) as shown in the image below:</p>
<p><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="emit Function outputs Keys &amp; (associated) Values" border="0" alt="emit Function outputs Keys &amp; (associated) Values" src="http://new.mongovue.com/wp-content/uploads/2010/11/image4.png" width="935" height="824" /></p>
<p>Reduce operation aggregates different values for each given key using a user defined function. In other words, Reduce operation will take up each key (or CountryID) and then pick up all the values (in our case Json objects) created from Map step and then one-by-one process them using a custom defined logic. Lets look at the signature of Reduce function.</p>
<p>&#160;</p>
<pre>function /*object*/ ReduceCode(key, arr_values) {

}</pre>
<p>&#160;</p>
<p>Reduce takes 2 parameters – 1) Key 2) An array of values (number of values outputted from Map step). Output of Reduce is an object. It is important to note that Reduce can be called multiple times on a single key! Yes, you read it correctly. It is not that difficult to think actually – consider a case where your data is huge and it lies on 2 different servers. It would be ideal to perform a Reduce on the given key on first server, and then perform a Reduce for the same key on second server. And then do a Reduce on the results of these two reduced values.</p>
<p>Here is a picture explaining Reduce step.</p>
<p><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Reduce step" border="0" alt="Reduce step" src="http://new.mongovue.com/wp-content/uploads/2010/11/image5.png" width="941" height="331" /></p>
<p>The picture above shows Reduce being called twice. This is just can example. To be frank, we don’t know how MongoDB executes Reduce. We don’t know which key it is going to be reduced first and which key last. We also don’t know how many times it is going to call reduce for a key. This optimization is better left with MongoDB itself as it finds the most suitable parallel execution for every MapReduce command.</p>
<p>What we do know is that if Reduce is executed more than once then the value returned will be passed in a subsequent reduce as part of input.</p>
<p>For our given problem, we want Reduce to output all the cities of a given country (so that we can then try to find the closest two). So the expected format of final reduced value (r<sub>F</sub>) is:</p>
<p>&#160;</p>
<pre>{
	&quot;data&quot; : [
			{ city E },
			{ city B },
			{ . . .  }
	]
}     </pre>
<p>&#160;</p>
<p>But the input values in Reduce array (param 2) should have exactly the same format as the output, as the output may be intermediate and may participate in further Reduce. So lets mould the Map function to produce values in&#160; the above desired format.</p>
<p>&#160;</p>
<pre>function MapCode() {
	emit(this.CountryID,
	{ &quot;data&quot;:
		[
			{
				&quot;city&quot;: this.City,
				&quot;lat&quot;:  this.Latitude,
				&quot;lon&quot;:  this.Longitude
			}
		]
	});
}</pre>
<p>&#160;</p>
<p>Our reduce function simply assimilates all the cities.</p>
<p>&#160;</p>
<pre>function ReduceCode(key, values) {

	var reduced = {&quot;data&quot;:[]};
	for (var i in values) {
		var inter = values[i];
		for (var j in inter.data) {
			reduced.data.push(inter.data[j]);
		}
	}

	return reduced;
}</pre>
<p>&#160;</p>
<p>This brings us to Finalize step. Finalize is used to do any required transformation on the final output of Reduce. The function signature of Finalize is given below:</p>
<p>&#160;</p>
<pre>function /*object*/ FinalizeCode(key, value) {

}</pre>
<p>&#160;</p>
<p>The function takes a a key value pair, and outputs a value. After the Reduce is complete, MongoDB runs Finalize on each key’s final reduced value. The output of Finalize for all keys is put in a collection, and it is this collection which is the result of Map Reduce. You can give it a desired name, and if left unspecified, MongoDB selects a collection name for you.</p>
<p><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://new.mongovue.com/wp-content/uploads/2010/11/image6.png" width="621" height="198" /></p>
<p>In our case, we’ll use Finalize to find the closest 2 cities out of all the given cities in a country. Here is the Finalize function.</p>
<p>&#160;</p>
<pre>function Finalize(key, reduced) {

	if (reduced.data.length == 1) {
		return { &quot;message&quot; : &quot;This Country contains only 1 City&quot; };
	}

	var min_dist = 999999999999;
	var city1 = { &quot;name&quot;: &quot;&quot; };
	var city2 = { &quot;name&quot;: &quot;&quot; };

	var c1;
	var c2;
	var d;
	for (var i in reduced.data) {
		for (var j in reduced.data) {
			if (i&gt;=j) continue;
			c1 = reduced.data[i];
			c2 = reduced.data[j];
			d = Math.sqrt((c1.lat-c2.lat)*(c1.lat-c2.lat)+(c1.lon-c2.lon)*(c1.lon-c2.lon));
			if (d &lt; min_dist &amp;&amp; d &gt; 0) {
				min_dist = d;
				city1 = c1;
				city2 = c2;
			}
		}
	}

	return {&quot;city1&quot;: city1.name, &quot;city2&quot;: city2.name, &quot;dist&quot;: min_dist};
}</pre>
<p>&#160;</p>
<p>This completes our MapReduce solutions as well. We just need to filter out US cities when we invoke this – that is easy enough to do with a simple condition:</p>
<p>&#160;</p>
<pre>{
	CountryID: { $ne: 254 }  /* 254 is US CountryID */
}</pre>
<p><strong></strong></p>
<p><strong></strong></p>
<p><strong></strong></p>
<p><strong>Points to note</strong></p>
<ul>
<li>While this is clearly not intended to be a benchmark, but still, the SQL solution took about 100 sec on my laptop (the view creation took only 1 sec, rest is spent in grouping and joins. Using a temp table/indexes would speed this up). </li>
<li>Map Reduce took 6 seconds to run </li>
<li>There are other SQL and MapReduce solutions to this problem. For example, you could open cursors in SQL and iterate through all the records in nested for loops. Similarly, you could do an 2 back to back MapReduce operations without resorting to use of Finalize step. I’ll try to explore these in a future post. </li>
</ul>
<p>If you want to learn about how to execute these steps in MongoVUE, then refer to this <a href="http://www.mongovue.com/2011/04/05/how-to-perform-mapreduce-operations-in-mongovue-a-step-by-step-guide/">step-by-step tutorial</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.mongovue.com/2010/11/03/yet-another-mongodb-map-reduce-tutorial/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>Monitor your MongoDB servers</title>
		<link>http://www.mongovue.com/2010/10/24/monitor-your-mongodb-servers/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=monitor-your-mongodb-servers</link>
		<comments>http://www.mongovue.com/2010/10/24/monitor-your-mongodb-servers/#comments</comments>
		<pubDate>Sun, 24 Oct 2010 15:56:40 +0000</pubDate>
		<dc:creator>ishaan</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[live]]></category>
		<category><![CDATA[mongoDB]]></category>
		<category><![CDATA[MongoVUE]]></category>
		<category><![CDATA[Monitoring]]></category>
		<category><![CDATA[real-time]]></category>

		<guid isPermaLink="false">http://blog.mongovue.com/2010/10/24/monitor-your-mongodb-servers/</guid>
		<description><![CDATA[FourSquare is a popular website that uses MongoDB to store data. They make especially good use of MongoDB’s 2D indexes to provide geo-location features to their users. FourSquare recently had an outage and their site was unavailable for around 11 hours. Eliot Horowitz (10gen’s CTO) describes reasons for this outage and his thoughts on prevention [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.foursquare.com" target="_blank">FourSquare</a> is a popular website that uses MongoDB to store data. They make especially good use of MongoDB’s 2D indexes to provide geo-location features to their users. FourSquare recently had an outage and their site was unavailable for around 11 hours. Eliot Horowitz (10gen’s CTO) describes reasons for this outage and his thoughts on prevention in <a href="http://groups.google.com/group/mongodb-user/browse_thread/thread/528a94f287e9d77e?pli=1" target="_blank">this post</a>.</p>
<p>This instance highlighted the critical need to monitor the performance of production servers. There are a number of services available that provide monitoring of servers with the ability to store historical data and provide nice graphs and charts of key metrics including CPU, IO, Memory etc.</p>
<p>The new version of MongoVUE – 0.6.5, includes a simple and easy capability allowing you to monitor your MongoDB’s performance right from your desktop!</p>
<p><strong> </strong></p>
<p><strong>Step 1</strong>: Fire up MongoVUE. We are not going to use the “Database Explorer”, so lets unpin it. There is a new button available in the toolbar &#8211; “Monitoring”, click on this.</p>
<p><img style="display: inline; border-width: 0px;" title="Click the &quot;Monitoring&quot; button" src="http://new.mongovue.com/wp-content/uploads/2010/10/image2.png" border="0" alt="Click the &quot;Monitoring&quot; button" width="661" height="109" /></p>
<p>&nbsp;</p>
<p><strong>Step 2</strong>: Now click on the “Add Server” button. This brings up the Connection Manager – select the server that you want to Monitor.</p>
<p><img style="display: inline; border-width: 0px;" title="Click the &quot;Add Server&quot; button" src="http://new.mongovue.com/wp-content/uploads/2010/10/image3.png" border="0" alt="Click the &quot;Add Server&quot; button" width="654" height="458" /></p>
<p>&nbsp;</p>
<p><strong>Step 3</strong>: The server is added to the screen and you can see it update its values in real time. The default refresh interval is 1 second. You can easily change this.</p>
<p><img style="display: inline; border-width: 0px;" title="Selected server (&quot;localhost&quot;) has its MongoDB values updated in real-time" src="http://new.mongovue.com/wp-content/uploads/2010/10/image4.png" border="0" alt="Selected server (&quot;localhost&quot;) has its MongoDB values updated in real-time" width="655" height="456" /></p>
<p>&nbsp;</p>
<p>That is it. You are done. Just keep this window open, and you can continuously monitor your MongoDB performance. To monitor more servers, go to step 2 and add more servers.</p>
<p>&nbsp;</p>
<p>Important points to Note:</p>
<ul>
<li>MongoVUE does not store any real-time data on disk</li>
<li>MongoVUE polls your server for only MongoDB stats, so you won’t get other (typical) monitors like Disk Space, CPU etc</li>
<li>MongoVUE uses db.serverStatus() command to get the data. This command requires admin privileges and may not work on some hosted MongoDB services like MongoHQ</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.mongovue.com/2010/10/24/monitor-your-mongodb-servers/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Updating Collections</title>
		<link>http://www.mongovue.com/2010/09/14/updating-collections/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=updating-collections</link>
		<comments>http://www.mongovue.com/2010/09/14/updating-collections/#comments</comments>
		<pubDate>Tue, 14 Sep 2010 17:15:55 +0000</pubDate>
		<dc:creator>ishaan</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[mongoDB]]></category>
		<category><![CDATA[MongoVUE]]></category>
		<category><![CDATA[Updates]]></category>

		<guid isPermaLink="false">http://blog.mongovue.com/2010/09/14/updating-collections/</guid>
		<description><![CDATA[With the release of version 0.5.0, MongoVUE has the ability to Update documents in MongoDB collections. So let’s explore this functionality with an example. Let’s use “cities” collection. The first document in this collection is given below: { &#34;_id&#34;: &#34;4c6cd19abac70617980003ea&#34;, &#34;CityId&#34;: 13487, &#34;CountryID&#34;: 43, &#34;RegionID&#34;: 37, &#34;City&#34;: &#34;Newcastle&#34;, &#34;Latitude&#34;: 43.9169998168945, &#34;Longitude&#34;: -78.5830001831055, &#34;TimeZone&#34;: &#34;-05:00&#34;, &#34;DmaId&#34;: [...]]]></description>
			<content:encoded><![CDATA[<p>With the release of version 0.5.0, MongoVUE has the ability to Update documents in MongoDB collections. So let’s explore this functionality with an example.</p>
<p>Let’s use “cities” collection. The first document in this collection is given below:</p>
<pre>{
  &quot;_id&quot;: &quot;4c6cd19abac70617980003ea&quot;,
  &quot;CityId&quot;: 13487,
  &quot;CountryID&quot;: 43,
  &quot;RegionID&quot;: 37,
  &quot;City&quot;: &quot;Newcastle&quot;,
  &quot;Latitude&quot;: 43.9169998168945,
  &quot;Longitude&quot;: -78.5830001831055,
  &quot;TimeZone&quot;: &quot;-05:00&quot;,
  &quot;DmaId&quot;: 0,
  &quot;County&quot;: &quot;NEWC&quot;,
  &quot;Code&quot;: &quot;&quot;
}</pre>
<p><strong>The Goal: </strong></p>
<p>We want to update all the cities of Country 43 so that “Code” key contains a value of “abc”. (What an arbitrary problem!)</p>
<p>If we were using a relational database, the solution SQL query would be very simple.</p>
<pre>UPDATE cities SET Code = &quot;abc&quot; WHERE CountryID = 43</pre>
<p>&#160;</p>
<p>To see how we can do this in MongoVUE, lets fire it up and select the “cities” collection in Database Explorer. Now click on “Update” button in the toolbar to get the Update View:</p>
<p><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Update View, once it opens up" border="0" alt="Update View, once it opens up" src="http://new.mongovue.com/wp-content/uploads/2010/09/image1.png" width="640" height="508" /> </p>
<p>&#160;</p>
<p>One the left site of Update View, you can see a text area to write your conditions or queries (equivalent to WHERE clause in SQL paradigm) that’ll select the documents that need to be update. Lets fill this up.</p>
<p><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Find query condition" border="0" alt="Find query condition" src="http://new.mongovue.com/wp-content/uploads/2010/09/image2.png" width="320" height="368" /> </p>
</p>
<p>&#160;</p>
<p>Once you write your query, you can hit the “Count” button to see how many documents it will affect. You can also hit the “Find” button to get those documents.</p>
<p><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="When you click &quot;Count&quot;, you&#39;ll see this" border="0" alt="When you click &quot;Count&quot;, you&#39;ll see this" src="http://new.mongovue.com/wp-content/uploads/2010/09/image3.png" width="373" height="142" /> </p>
<p>&#160;</p>
<p>We’ll now program the data that we want to modify. We do this in the Update options box on the right side.</p>
<p><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="What needs to be modified" border="0" alt="What needs to be modified" src="http://new.mongovue.com/wp-content/uploads/2010/09/image4.png" width="324" height="339" /> </p>
<p>&#160;</p>
<p>Just hit the one of 2 Update buttons, and we’re done. “Update 1”, will update the first matching document. And “Update All” will update all the matching documents. The final result is shown below. You can see that all 573 documents got updated when I pressed “Update All”.</p>
<p><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Final result after Update" border="0" alt="Final result after Update" src="http://new.mongovue.com/wp-content/uploads/2010/09/image5.png" width="640" height="508" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.mongovue.com/2010/09/14/updating-collections/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
	</channel>
</rss>

