Lucene.Net.Analysis.CollationTestbase.TestFarsiRangeQueryCollating C# (CSharp) Method

TestFarsiRangeQueryCollating() public method

public TestFarsiRangeQueryCollating ( Analyzer analyzer, BytesRef firstBeg, BytesRef firstEnd, BytesRef secondBeg, BytesRef secondEnd ) : void
analyzer Analyzer
firstBeg BytesRef
firstEnd BytesRef
secondBeg BytesRef
secondEnd BytesRef
return void
        public virtual void TestFarsiRangeQueryCollating(Analyzer analyzer, BytesRef firstBeg, BytesRef firstEnd, BytesRef secondBeg, BytesRef secondEnd)
        {
            Directory dir = NewDirectory();
            IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT, analyzer));
            Document doc = new Document();

            // 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 TermRangeQuery with a Farsi
            // Collator (or an Arabic one for the case when Farsi is not supported).
            doc.Add(new TextField("content", "\u0633\u0627\u0628", Field.Store.YES));
            writer.AddDocument(doc);
            writer.Dispose();
            IndexReader reader = DirectoryReader.Open(dir);
            IndexSearcher searcher = new IndexSearcher(reader);

            Search.Query query = new TermRangeQuery("content", firstBeg, firstEnd, true, true);
            ScoreDoc[] hits = searcher.Search(query, null, 1000).ScoreDocs;
            Assert.AreEqual(0, hits.Length, "The index Term should not be included.");

            query = new TermRangeQuery("content", secondBeg, secondEnd, true, true);
            hits = searcher.Search(query, null, 1000).ScoreDocs;
            Assert.AreEqual(1, hits.Length, "The index Term should be included.");
            reader.Dispose();
            dir.Dispose();
        }