Lucene.Net.QueryParsers.TestQueryParser.TestFarsiRangeCollating C# (CSharp) Method

TestFarsiRangeCollating() private method

private TestFarsiRangeCollating ( ) : void
return void
		public virtual void  TestFarsiRangeCollating()
		{
			
			RAMDirectory ramDir = new RAMDirectory();
			IndexWriter iw = new IndexWriter(ramDir, new WhitespaceAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
			Document doc = new Document();
			doc.Add(new Field("content", "\u0633\u0627\u0628", Field.Store.YES, Field.Index.NOT_ANALYZED));
			iw.AddDocument(doc);
			iw.Close();
		    IndexSearcher is_Renamed = new IndexSearcher(ramDir, true);

            QueryParser qp = new QueryParser(Version.LUCENE_CURRENT, "content", new WhitespaceAnalyzer());
			
			// Neither Java 1.4.2 nor 1.5.0 has Farsi Locale collation available in
			// RuleBasedCollator.  However, the Arabic Locale seems to order the Farsi
			// characters properly.
			System.Globalization.CompareInfo c = new System.Globalization.CultureInfo("ar").CompareInfo;
			qp.RangeCollator = c;
			
			// Unicode order would include U+0633 in [ U+062F - U+0698 ], but Farsi
			// orders the U+0698 character before the U+0633 character, so the single
			// index Term below should NOT be returned by a ConstantScoreRangeQuery
			// with a Farsi Collator (or an Arabic one for the case when Farsi is not
			// supported).
			
			// Test ConstantScoreRangeQuery
			qp.MultiTermRewriteMethod = MultiTermQuery.CONSTANT_SCORE_FILTER_REWRITE;
			ScoreDoc[] result = is_Renamed.Search(qp.Parse("[ \u062F TO \u0698 ]"), null, 1000).ScoreDocs;
			Assert.AreEqual(0, result.Length, "The index Term should not be included.");
			
			result = is_Renamed.Search(qp.Parse("[ \u0633 TO \u0638 ]"), null, 1000).ScoreDocs;
			Assert.AreEqual(1, result.Length, "The index Term should be included.");
			
			// Test TermRangeQuery
			qp.MultiTermRewriteMethod = MultiTermQuery.SCORING_BOOLEAN_QUERY_REWRITE;
			result = is_Renamed.Search(qp.Parse("[ \u062F TO \u0698 ]"), null, 1000).ScoreDocs;
			Assert.AreEqual(0, result.Length, "The index Term should not be included.");
			
			result = is_Renamed.Search(qp.Parse("[ \u0633 TO \u0638 ]"), null, 1000).ScoreDocs;
			Assert.AreEqual(1, result.Length, "The index Term should be included.");
			
			is_Renamed.Close();
		}