title: How to extract specific fields from Mongo DB collection
body: <p>I have 2250 records in my mongo collection.</p>
  
  <p>Below is one record from that collection  -</p>
  
  <pre><code>"_id" : bjectId("57e57e3fb04c6373f7000002"),
  "message" : "&lt;logentry   revision='15234'&gt;&lt;author&gt;447085&lt;/author&gt;&lt;date&gt;2016-07-19T12:39:19.707782Z&lt;/date&gt;&lt;paths&gt;&lt;path   prop-mods='false'   text-mods='true'   kind='file'   action='M'&gt;/itdp/branches/itdpux/branches/base/itdp2.0/src/com/cts/race/beans/ProgramChronicleBean.java&lt;/path&gt;&lt;/paths&gt;&lt;msg&gt;day week month function addition &lt;/msg&gt;&lt;/logentry&gt;",
      "@version" : "1",
      "@timestamp" : ISODate("2015-09-23T19:10:54.824Z"),
      "path" : "C:/DevInsight/svnpredictor/svn/svn.log",
      "host" : "WIN-5BRSCLOQIVN",
      "type" : "XML",
      "author" : "447085",
      "revision" : "15234",
      "date" : "2016-07-19T12:39:19.707782Z",
      "paths" : { "path" : [ 
              {   "action" : "M",
                  "kind" : "file",
                  "prop-mods" : "false",
                  "text-mods" : "true",
                  "content" : "/itdp/branches/itdpux/branches/base/itdp2.0/src/com/cts/race/beans/ProgramChronicleBean.java"
              } ] }
  </code></pre>
  
  <p>I want to extract <strong>revision,content</strong> fields of a record within certain date range. The mongoexport should be stored to a CSV and with fields as <strong>revision_id,file_name</strong> . I have tried below command </p>
  
  <pre><code>C:\mongodb\bin\mongoexport --db dbname --collection cname -f 'revision,paths.path.content' --query "{'date': { '$lt': {'$date' : ISODate('%1')} , '$gte': {'$date': ISODate('%2') }}}"  --out "C:\test\mongodata.csv"
  </code></pre>
  
  <p>I get below output with the above command-</p>
  
  <p>{"_id":{"$oid":"57e57e3fb04c6373f7000003"},"paths":{"path":[{ ///whole paths tag content/// }]}</p>
  
  <p>My actual output should be as below -</p>
  
  <p>revision_id,file_name
  15234,/itdp/branches/itdpux/branches/base/itdp2.0/web/xhtml/progchronicle_iux.xhtml</p>
  
  <p>One good thing with the command is i am able to extract all the records which are withing the date range i specified.</p>
  
  <p>Kindly, check my code and help me</p>