Assembles a IQueryBuilder which uses only core Lucene Query objects
Inheritance: IQueryBuilder
Ejemplo n.º 1
0
        public override void BeforeClass()
        {
            base.BeforeClass();

            // TODO: rewrite test (this needs to set QueryParser.enablePositionIncrements, too, for work with CURRENT):
            Analyzer analyzer = new MockAnalyzer(Random(), MockTokenizer.WHITESPACE, true, MockTokenFilter.ENGLISH_STOPSET);

            //initialize the parser
            builder = new CorePlusExtensionsParser("contents", analyzer);

            TextReader d = new StreamReader(
                typeof(TestParser).getResourceAsStream("reuters21578.txt"), Encoding.ASCII);

            dir = NewDirectory();
            IndexWriter writer = new IndexWriter(dir, NewIndexWriterConfig(TEST_VERSION_CURRENT, analyzer));
            String      line   = d.ReadLine();

            while (line != null)
            {
                int      endOfDate = line.IndexOf('\t');
                String   date      = line.Substring(0, endOfDate).Trim();
                String   content   = line.Substring(endOfDate).Trim();
                Document doc       = new Document();
                doc.Add(NewTextField("date", date, Field.Store.YES));
                doc.Add(NewTextField("contents", content, Field.Store.YES));
                doc.Add(new Int32Field("date2", Convert.ToInt32(date), Field.Store.NO));
                writer.AddDocument(doc);
                line = d.ReadLine();
            }
            d.Dispose();
            writer.Dispose();
            reader   = DirectoryReader.Open(dir);
            searcher = NewSearcher(reader);
        }
Ejemplo n.º 2
0
 public static void AfterClass()
 {
     reader.Dispose();
     dir.Dispose();
     reader   = null;
     searcher = null;
     dir      = null;
     builder  = null;
 }
Ejemplo n.º 3
0
 public override void AfterClass()
 {
     reader.Dispose();
     dir.Dispose();
     reader   = null;
     searcher = null;
     dir      = null;
     builder  = null;
     base.AfterClass();
 }
Ejemplo n.º 4
0
        /*
         * @see TestCase#setUp()
         */

        public override void SetUp()
        {
            base.SetUp();

            analyzer = new MockAnalyzer(Random);
            //Create an index
            dir = NewDirectory();
            IndexWriter w = new IndexWriter(dir, NewIndexWriterConfig(TEST_VERSION_CURRENT, analyzer));

            foreach (String docFieldValue in docFieldValues)
            {
                w.AddDocument(getDocumentFromString(docFieldValue));
            }
            w.ForceMerge(1);
            w.Dispose();
            reader   = DirectoryReader.Open(dir);
            searcher = NewSearcher(reader);

            //initialize the parser
            builder = new CorePlusExtensionsParser("artist", analyzer);
        }
Ejemplo n.º 5
0
        /*
          * @see TestCase#setUp()
          */

        public override void SetUp()
        {
            base.SetUp();

            analyzer = new MockAnalyzer(Random());
            //Create an index
            dir = NewDirectory();
            IndexWriter w = new IndexWriter(dir, NewIndexWriterConfig(TEST_VERSION_CURRENT, analyzer));
            foreach (String docFieldValue in docFieldValues)
            {
                w.AddDocument(getDocumentFromString(docFieldValue));
            }
            w.ForceMerge(1);
            w.Dispose();
            reader = DirectoryReader.Open(dir);
            searcher = NewSearcher(reader);

            //initialize the parser
            builder = new CorePlusExtensionsParser("artist", analyzer);

        }