/// <summary>
        /// Set up a new index in RAM with three test phrases and the supplied Analyzer.
        /// </summary>
        /// <exception cref="Exception"> if an error occurs with index writer or searcher </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: @Override public void setUp() throws Exception
        public override void setUp()
        {
            base.setUp();
            analyzer  = new ShingleAnalyzerWrapper(new MockAnalyzer(random(), MockTokenizer.WHITESPACE, false), 2);
            directory = newDirectory();
            IndexWriter writer = new IndexWriter(directory, new IndexWriterConfig(TEST_VERSION_CURRENT, analyzer));

            Document doc;

            doc = new Document();
            doc.add(new TextField("content", "please divide this sentence into shingles", Field.Store.YES));
            writer.addDocument(doc);

            doc = new Document();
            doc.add(new TextField("content", "just another test sentence", Field.Store.YES));
            writer.addDocument(doc);

            doc = new Document();
            doc.add(new TextField("content", "a sentence which contains no test", Field.Store.YES));
            writer.addDocument(doc);

            writer.close();

            reader   = DirectoryReader.open(directory);
            searcher = newSearcher(reader);
        }
Example #2
0
        protected override IndexWriter CreateIndexWriter(Directory directory)
        {
            var indexWriter = new IndexWriter(directory, null, IndexWriter.MaxFieldLength.UNLIMITED);

            indexWriter.setSimilarity(CreateSimilarity());
            return(indexWriter);
        }
        /// <summary>
        /// Set up a new index in RAM with three test phrases and the supplied Analyzer.
        /// </summary>
        /// <exception cref="Exception"> if an error occurs with index writer or searcher </exception>
        //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
        //ORIGINAL LINE: @Override public void setUp() throws Exception
        public override void setUp()
        {
            base.setUp();
            analyzer = new ShingleAnalyzerWrapper(new MockAnalyzer(random(), MockTokenizer.WHITESPACE, false), 2);
            directory = newDirectory();
            IndexWriter writer = new IndexWriter(directory, new IndexWriterConfig(TEST_VERSION_CURRENT, analyzer));

            Document doc;
            doc = new Document();
            doc.add(new TextField("content", "please divide this sentence into shingles", Field.Store.YES));
            writer.addDocument(doc);

            doc = new Document();
            doc.add(new TextField("content", "just another test sentence", Field.Store.YES));
            writer.addDocument(doc);

            doc = new Document();
            doc.add(new TextField("content", "a sentence which contains no test", Field.Store.YES));
            writer.addDocument(doc);

            writer.close();

            reader = DirectoryReader.open(directory);
            searcher = newSearcher(reader);
        }
        //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
        //ORIGINAL LINE: @Override public void setUp() throws Exception
        public override void setUp()
        {
            base.setUp();
            directory = newDirectory();
            IndexWriter writer = new IndexWriter(directory, new IndexWriterConfig(TEST_VERSION_CURRENT, new SimpleAnalyzer(TEST_VERSION_CURRENT)));

            Document doc = new Document();
            doc.add(new StringField("partnum", "Q36", Field.Store.YES));
            doc.add(new TextField("description", "Illidium Space Modulator", Field.Store.YES));
            writer.addDocument(doc);

            writer.close();

            reader = DirectoryReader.open(directory);
            searcher = newSearcher(reader);
        }
Example #5
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: @Override public void setUp() throws Exception
        public override void setUp()
        {
            base.setUp();
            directory = newDirectory();
            IndexWriter writer = new IndexWriter(directory, new IndexWriterConfig(TEST_VERSION_CURRENT, new SimpleAnalyzer(TEST_VERSION_CURRENT)));

            Document doc = new Document();

            doc.add(new StringField("partnum", "Q36", Field.Store.YES));
            doc.add(new TextField("description", "Illidium Space Modulator", Field.Store.YES));
            writer.addDocument(doc);

            writer.close();

            reader   = DirectoryReader.open(directory);
            searcher = newSearcher(reader);
        }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void testIndexWriter_LUCENE4656() throws java.io.IOException
        public virtual void testIndexWriter_LUCENE4656()
        {
            Directory   directory = newDirectory();
            IndexWriter writer    = new IndexWriter(directory, newIndexWriterConfig(TEST_VERSION_CURRENT, null));

            TokenStream ts = new EmptyTokenStream();

            assertFalse(ts.hasAttribute(typeof(TermToBytesRefAttribute)));

            Document doc = new Document();

            doc.add(new StringField("id", "0", Field.Store.YES));
            doc.add(new TextField("description", ts));

            // this should not fail because we have no TermToBytesRefAttribute
            writer.addDocument(doc);

            assertEquals(1, writer.numDocs());

            writer.close();
            directory.close();
        }
Example #7
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: ReadOnlyIndexPartition(java.io.File partitionFolder, org.apache.lucene.store.Directory directory) throws java.io.IOException
        internal ReadOnlyIndexPartition(File partitionFolder, Directory directory) : base(partitionFolder, directory)
        {
            this._searcherManager = new SearcherManager(directory, new SearcherFactory());
        }
 public override string segString(Directory dir)
 {
     return "SortingMergeSpec(" + base.segString(dir) + ", sorter=" + outerInstance.sorter + ")";
 }
Example #9
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public AbstractIndexPartition createPartition(java.io.File partitionFolder, org.apache.lucene.store.Directory directory) throws java.io.IOException
        public override AbstractIndexPartition CreatePartition(File partitionFolder, Directory directory)
        {
            return(new ReadOnlyIndexPartition(partitionFolder, directory));
        }
Example #10
0
 public AbstractIndexPartition(File partitionFolder, Directory directory)
 {
     this.PartitionFolder   = partitionFolder;
     this.DirectoryConflict = directory;
 }
Example #11
0
 protected override void OnIndexInitialised(Directory directory)
 {
 }
Example #12
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public WritableIndexPartition(java.io.File partitionFolder, org.apache.lucene.store.Directory directory, org.apache.lucene.index.IndexWriterConfig writerConfig) throws java.io.IOException
        public WritableIndexPartition(File partitionFolder, Directory directory, IndexWriterConfig writerConfig) : base(partitionFolder, directory)
        {
            this._indexWriter     = new IndexWriter(directory, writerConfig);
            this._searcherManager = new SearcherManager(_indexWriter, new SearcherFactory());
        }
Example #13
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public AbstractIndexPartition createPartition(java.io.File partitionFolder, org.apache.lucene.store.Directory directory) throws java.io.IOException
        public override AbstractIndexPartition CreatePartition(File partitionFolder, Directory directory)
        {
            return(new WritableIndexPartition(partitionFolder, directory, _writerConfigFactory.newInstance()));
        }
Example #14
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @BeforeEach void setUp() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void SetUp()
        {
            _directory = DirectoryFactory.PERSISTENT.open(_testDirectory.directory());
        }