public virtual void TestPositionIncrement()
{
QueryParser qp = new QueryParser(Version.LUCENE_CURRENT, "a",
new StopAnalyzer(Version.LUCENE_CURRENT,
StopFilter.MakeStopSet(new[] {"the", "in", "are", "this"})));
qp.EnablePositionIncrements = true;
string qtxt = "\"the words in poisitions pos02578 are stopped in this phrasequery\"";
// 0 2 5 7 8
int[] expectedPositions = new int[] {1, 3, 4, 6, 9};
PhraseQuery pq = (PhraseQuery) qp.Parse(qtxt);
//System.out.println("Query text: "+qtxt);
//System.out.println("Result: "+pq);
Term[] t = pq.GetTerms();
int[] pos = pq.GetPositions();
for (int i = 0; i < t.Length; i++)
{
//System.out.println(i+". "+t[i]+" pos: "+pos[i]);
Assert.AreEqual(expectedPositions[i], pos[i], "term " + i + " = " + t[i] + " has wrong term-position!");
}
}