Lucene.Net.Search.Spans.TestPayloadSpans.TestShrinkToAfterShortestMatch C# (CSharp) Method

TestShrinkToAfterShortestMatch() private method

private TestShrinkToAfterShortestMatch ( ) : void
return void
		public virtual void  TestShrinkToAfterShortestMatch()
		{
			RAMDirectory directory = new RAMDirectory();
			IndexWriter writer = new IndexWriter(directory, new TestPayloadAnalyzer(this), IndexWriter.MaxFieldLength.LIMITED);
			Document doc = new Document();
			doc.Add(new Field("content", new System.IO.StreamReader( new System.IO.MemoryStream( System.Text.Encoding.ASCII.GetBytes( "a b c d e f g h i j a k")))));
			writer.AddDocument(doc);
			writer.Close();
			
			IndexSearcher is_Renamed = new IndexSearcher(directory, true);
			
			SpanTermQuery stq1 = new SpanTermQuery(new Term("content", "a"));
			SpanTermQuery stq2 = new SpanTermQuery(new Term("content", "k"));
			SpanQuery[] sqs = new SpanQuery[]{stq1, stq2};
			SpanNearQuery snq = new SpanNearQuery(sqs, 1, true);
			Spans spans = snq.GetSpans(is_Renamed.IndexReader);
			
			TopDocs topDocs = is_Renamed.Search(snq, 1);
			System.Collections.Hashtable payloadSet = new System.Collections.Hashtable();
			for (int i = 0; i < topDocs.ScoreDocs.Length; i++)
			{
				while (spans.Next())
				{
					System.Collections.Generic.ICollection<byte[]> payloads = spans.GetPayload();
					
					for (System.Collections.IEnumerator it = payloads.GetEnumerator(); it.MoveNext(); )
					{
						CollectionsHelper.AddIfNotContains(payloadSet, new System.String(System.Text.UTF8Encoding.UTF8.GetChars((byte[]) it.Current)));
					}
				}
			}
			Assert.AreEqual(2, payloadSet.Count);
			Assert.IsTrue(payloadSet.Contains("a:Noise:10"));
			Assert.IsTrue(payloadSet.Contains("k:Noise:11"));
		}