title: Mongodb Views in spark
body: <p>MongoDB provides support for the views from 3.4 version. How do I read the data from the views created in MongoDB in Apache Spark? I have tried treating the view as a regular collection in the <code>ReadConfig()</code>, and it is throwing the following error:</p>
  
  <pre><code>com.mongodb.MongoCommandException: Command failed with error 166: 'Namespace sample.&lt;view_name&gt; is a view, not a collection' on server &lt;server&gt;:27017. The full response is { "ok" : 0.0, "errmsg" : "Namespace sample.&lt;view_name&gt; is a view, not a collection", "code" : 166, "codeName" : "CommandNotSupportedOnView" }
  </code></pre>