Full text search in mongodb in .net
<p>I have to search contents in all documents in particular collection of mongodb in .net mvc . I have tried with mongodb shell by creating index successfully like here . </p>

<pre><code>db.collection_name.createIndex( { subject: "text" } )

db.collection_name.find( { $text: { $search: "search_word" } } )
</code></pre>

<p>It works fine . but when i put it in .net that gives me error . I googled it and got following solution for indexing . </p>

<pre><code> collection.EnsureIndex(new IndexKeysBuilder().Ascending("subject"));
</code></pre>

<p>now how can i run this query <code>db.collection_name.find( { $text: { $search: "coffee" } } )</code> .</p>

<p>I am trying in .net as following way .</p>

<pre><code>collection.CreateIndex("subject":"text");

var query = collection.Find({ $text: { $search: "coffe" }}); 
</code></pre>

<p>but I am getting error on first line "represents text as series of unicode ....syntax error "</p>

<p>2nd line error "There is no argument given that corresponds to required formal parameters " And "unexpected character $ ".</p>

<p>any suggestion will be appreciated . </p>