title: Exact phrase search using Lucene.net
body: <p>I am having trouble searching for an exact phrase using Lucene.NET 2.0.0.4  </p>
  
  <p>For example I am searching for "scope attribute sets the variable"  (including quotes) but receive no matches, I have confirmed 100% that the phrase exists.  </p>
  
  <p>Can anyone suggest where I am going wrong?  Is this even supported with Lucene.NET?  As usual the API documentation is not too helpful and a few CodeProject articles I've read don't specifically touch on this.</p>
  
  <p>Using the following code to create the index:</p>
  
  <pre><code>Directory dir = Lucene.Net.Store.FSDirectory.GetDirectory("Index", true);
  
  Analyzer analyzer = new Lucene.Net.Analysis.SimpleAnalyzer();
  
  IndexWriter indexWriter = new Lucene.Net.Index.IndexWriter(dir, analyzer,true);
  
  //create a document, add in a single field
  Lucene.Net.Documents.Document doc = new Lucene.Net.Documents.Document();
  
  Lucene.Net.Documents.Field fldContent = new Lucene.Net.Documents.Field(
      "content", File.ReadAllText(@"Documents\100.txt"),
      Lucene.Net.Documents.Field.Store.YES,
      Lucene.Net.Documents.Field.Index.TOKENIZED);
  
  doc.Add(fldContent);
  
  //write the document to the index
  indexWriter.AddDocument(doc);
  </code></pre>
  
  <p>I then search for a phrase using:</p>
  
  <pre><code>//state the file location of the index
  Directory dir = Lucene.Net.Store.FSDirectory.GetDirectory("Index", false);
  
  //create an index searcher that will perform the search
  IndexSearcher searcher = new Lucene.Net.Search.IndexSearcher(dir);
  
  QueryParser qp = new QueryParser("content", new SimpleAnalyzer());
  
  // txtSearch.Text  Contains a phrase such as "this is a phrase" 
  Query q=qp.Parse(txtSearch.Text);  
  
  
  //execute the query
  Lucene.Net.Search.Hits hits = searcher.Search(q);
  </code></pre>
  
  <p>The target document is about 7 MB plain text.  </p>
  
  <p>I have seen this <a href="https://stackoverflow.com/questions/343002/searching-phrases-in-lucene">previous question</a> however I don't want a proximity search, just an exact phrase search.</p>