title: Proximity Search example Lucene.Net
body: <p>I want to make a <a href="http://lucene.apache.org/java/2_3_2/queryparsersyntax.html#Proximity%20Searches" rel="nofollow noreferrer">Proximity Search</a> with Lucene.Net. I saw <a href="https://stackoverflow.com/questions/343002/searching-phrases-in-lucene">this question</a> where it looks like that was the answer for him, but no code was suplied. The Java documentation says to use the ~ character with the number of words in between, but I don't see where this character would go in the code. Anyone can give me an example of a Proximity Search using Lucene.Net?</p>
  
  <p><strong>Edit:</strong></p>
  
  <p>What I have so far:</p>
  
  <pre><code>IndexSearcher searcher = new IndexSearcher(this.Directory, true);
  
  string[] fieldList = new string[] { "Name", "Description" };
  
  List&lt;BooleanClause.Occur&gt; occurs = new List&lt;BooleanClause.Occur&gt;();
  foreach (string field in fieldList)
  {
       occurs.Add(BooleanClause.Occur.SHOULD);
  }
  
  
  Query searchQuery = MultiFieldQueryParser.Parse(this.LuceneVersion, query, fieldList, occurs.ToArray(), this.Analyzer);
  </code></pre>
  
  <p>If I try to add the "~" with any number on the MultiFieldQueryParser it errors out saying that for a FuzzySearch the values should be between 0.0 and 1.0, but I want a Proximity Search 3 words of separation Ex. "my search"~3</p>