Esempio n. 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void updateMultiplePartitionedIndex() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void UpdateMultiplePartitionedIndex()
        {
            using (SchemaIndex index = LuceneSchemaIndexBuilder.Create(_descriptor, _config).withFileSystem(_fileSystem).withIndexRootFolder(_testDir.directory("partitionedIndexForUpdates")).build())
            {
                index.create();
                index.open();
                AddDocumentToIndex(index, 45);

                index.IndexWriter.updateDocument(LuceneDocumentStructure.NewTermForChangeOrRemove(100), LuceneDocumentStructure.DocumentRepresentingProperties(( long )100, Values.intValue(100)));
                index.maybeRefreshBlocking();

                long documentsInIndex = Iterators.count(index.allDocumentsReader().GetEnumerator());
                assertEquals(46, documentsInIndex, "Index should contain 45 added and 1 updated document.");
            }
        }
Esempio n. 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void openClosePartitionedIndex() throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void OpenClosePartitionedIndex()
        {
            SchemaIndex reopenIndex = null;

            try
            {
                reopenIndex = LuceneSchemaIndexBuilder.Create(_descriptor, _config).withFileSystem(_fileSystem).withIndexRootFolder(new File(_testDir.directory("reopenIndexFolder"), "reopenIndex")).build();
                reopenIndex.open();

                AddDocumentToIndex(reopenIndex, 1);

                reopenIndex.close();
                assertFalse(reopenIndex.Open);

                reopenIndex.open();
                assertTrue(reopenIndex.Open);

                AddDocumentToIndex(reopenIndex, 10);

                reopenIndex.close();
                assertFalse(reopenIndex.Open);

                reopenIndex.open();
                assertTrue(reopenIndex.Open);

                reopenIndex.close();
                reopenIndex.open();
                AddDocumentToIndex(reopenIndex, 100);

                reopenIndex.maybeRefreshBlocking();

                using (LuceneAllDocumentsReader allDocumentsReader = reopenIndex.allDocumentsReader())
                {
                    assertEquals(111, allDocumentsReader.MaxCount(), "All documents should be visible");
                }
            }
            finally
            {
                if (reopenIndex != null)
                {
                    reopenIndex.close();
                }
            }
        }