Exemplo n.º 1
0
 /*public TestCustomSearcherSort(System.String name):base(name)
 {
 }*/
 
 /*[STAThread]
 public static void  Main(System.String[] argv)
 {
     // TestRunner.run(suite()); // {{Aroush-2.9}} how is this done in NUnit?
 }*/
 
 /*public static Test suite()
 {
     return new TestSuite(typeof(TestCustomSearcherSort));
 }*/
 
 
 // create an index for testing
 private Directory GetIndex()
 {
     RAMDirectory indexStore = new RAMDirectory();
     IndexWriter writer = new IndexWriter(indexStore, new StandardAnalyzer(Util.Version.LUCENE_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED);
     RandomGen random = new RandomGen(this, NewRandom());
     for (int i = 0; i < INDEX_SIZE; ++i)
     {
         // don't decrease; if to low the problem doesn't show up
         Document doc = new Document();
         if ((i % 5) != 0)
         {
             // some documents must not have an entry in the first sort field
             doc.Add(new Field("publicationDate_", random.GetLuceneDate(), Field.Store.YES, Field.Index.NOT_ANALYZED));
         }
         if ((i % 7) == 0)
         {
             // some documents to match the query (see below) 
             doc.Add(new Field("content", "test", Field.Store.YES, Field.Index.ANALYZED));
         }
         // every document has a defined 'mandant' field
         doc.Add(new Field("mandant", System.Convert.ToString(i % 3), Field.Store.YES, Field.Index.NOT_ANALYZED));
         writer.AddDocument(doc);
     }
     writer.Optimize();
     writer.Close();
     return indexStore;
 }
Exemplo n.º 2
0
        /*public TestCustomSearcherSort(System.String name):base(name)
         * {
         * }*/

        /*[STAThread]
         * public static void  Main(System.String[] argv)
         * {
         *      // TestRunner.run(suite()); // {{Aroush-2.9}} how is this done in NUnit?
         * }*/

        /*public static Test suite()
         * {
         *      return new TestSuite(typeof(TestCustomSearcherSort));
         * }*/


        // create an index for testing
        private Directory GetIndex()
        {
            RAMDirectory indexStore = new RAMDirectory();
            IndexWriter  writer     = new IndexWriter(indexStore, new StandardAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
            RandomGen    random     = new RandomGen(this, NewRandom());

            for (int i = 0; i < INDEX_SIZE; ++i)
            {
                // don't decrease; if to low the problem doesn't show up
                Document doc = new Document();
                if ((i % 5) != 0)
                {
                    // some documents must not have an entry in the first sort field
                    doc.Add(new Field("publicationDate_", random.GetLuceneDate(), Field.Store.YES, Field.Index.NOT_ANALYZED));
                }
                if ((i % 7) == 0)
                {
                    // some documents to match the query (see below)
                    doc.Add(new Field("content", "test", Field.Store.YES, Field.Index.ANALYZED));
                }
                // every document has a defined 'mandant' field
                doc.Add(new Field("mandant", System.Convert.ToString(i % 3), Field.Store.YES, Field.Index.NOT_ANALYZED));
                writer.AddDocument(doc);
            }
            writer.Optimize();
            writer.Close();
            return(indexStore);
        }