public void TestStopWordsInPhraseQuery()
{
var qp = new QueryParser(Version.LUCENE_CURRENT, "a", new StopAnalyzer(Version.LUCENE_CURRENT));
var result = qp.Parse("\"Query With Stopwords\"");
Assert.IsNotNull(result);
Assert.IsTrue(result is PhraseQuery);
Assert.AreEqual("a:\"query ? stopwords\"", result.ToString());
result = qp.Parse("\"Query OR Stopwords\"");
Assert.IsNotNull(result);
Assert.IsTrue(result is PhraseQuery);
Assert.AreEqual("a:\"query ? stopwords\"", result.ToString());
result = qp.Parse("\"Query and Stopwords\"");
Assert.IsNotNull(result);
Assert.IsTrue(result is PhraseQuery);
Assert.AreEqual("a:\"query ? stopwords\"", result.ToString());
result = qp.Parse("\"Query AND Stopwords\"");
Assert.IsNotNull(result);
Assert.IsTrue(result is PhraseQuery);
Assert.AreEqual("a:\"query ? stopwords\"", result.ToString());
// Disable position increments to attempt to remove ? from PhraseQuery.ToString()
qp.EnablePositionIncrements = false;
result = qp.Parse("\"Query With Stopwords\"");
Assert.IsNotNull(result);
Assert.IsTrue(result is PhraseQuery);
Assert.AreEqual("a:\"query stopwords\"", result.ToString());
result = qp.Parse("\"Query OR Stopwords\"");
Assert.IsNotNull(result);
Assert.IsTrue(result is PhraseQuery);
Assert.AreEqual("a:\"query stopwords\"", result.ToString());
result = qp.Parse("\"Query and Stopwords\"");
Assert.IsNotNull(result);
Assert.IsTrue(result is PhraseQuery);
Assert.AreEqual("a:\"query stopwords\"", result.ToString());
result = qp.Parse("\"Query AND Stopwords\"");
Assert.IsNotNull(result);
Assert.IsTrue(result is PhraseQuery);
Assert.AreEqual("a:\"query stopwords\"", result.ToString());
}
}