public SetOpenMode ( OpenMode_e openMode ) : |
||
openMode | OpenMode_e | |
리턴 |
private static IndexWriter GetWriter(Directory directory) { MergePolicy policy = new LogByteSizeMergePolicy(); IndexWriterConfig conf = new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random)); conf.SetMergePolicy(policy); conf.SetOpenMode(OpenMode.CREATE_OR_APPEND); IndexWriter writer = new IndexWriter(directory, conf); return(writer); }
public virtual void TestTypeChangeAfterOpenCreate() { Directory dir = NewDirectory(); IndexWriterConfig conf = NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random)); IndexWriter writer = new IndexWriter(dir, (IndexWriterConfig)conf.Clone()); Document doc = new Document(); doc.Add(new NumericDocValuesField("dv", 0L)); writer.AddDocument(doc); writer.Dispose(); conf.SetOpenMode(OpenMode.CREATE); writer = new IndexWriter(dir, (IndexWriterConfig)conf.Clone()); doc = new Document(); doc.Add(new SortedDocValuesField("dv", new BytesRef("foo"))); writer.AddDocument(doc); writer.Dispose(); dir.Dispose(); }
public virtual void TestMixedTypesAfterReopenCreate() { Directory dir = NewDirectory(); IndexWriter w = new IndexWriter(dir, NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random))); Document doc = new Document(); doc.Add(new NumericDocValuesField("foo", 0)); w.AddDocument(doc); w.Dispose(); IndexWriterConfig iwc = NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random)); iwc.SetOpenMode(OpenMode.CREATE); w = new IndexWriter(dir, iwc); doc = new Document(); doc.Add(new SortedDocValuesField("foo", new BytesRef("hello"))); w.AddDocument(doc); w.Dispose(); dir.Dispose(); }
public virtual void TestTryDeleteDocument() { Directory d = NewDirectory(); IndexWriterConfig iwc = new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random())); IndexWriter w = new IndexWriter(d, iwc); Document doc = new Document(); w.AddDocument(doc); w.AddDocument(doc); w.AddDocument(doc); w.Dispose(); iwc = new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random())); iwc.SetOpenMode(IndexWriterConfig.OpenMode_e.APPEND); w = new IndexWriter(d, iwc); IndexReader r = DirectoryReader.Open(w, false); Assert.IsTrue(w.TryDeleteDocument(r, 1)); Assert.IsTrue(w.TryDeleteDocument(r.Leaves[0].Reader, 0)); r.Dispose(); w.Dispose(); r = DirectoryReader.Open(d); Assert.AreEqual(2, r.NumDeletedDocs); Assert.IsNotNull(MultiFields.GetLiveDocs(r)); r.Dispose(); d.Dispose(); }
/// <summary> /// Override this to customize index settings, e.g. which /// codec to use. /// </summary> protected internal virtual IndexWriterConfig GetIndexWriterConfig(LuceneVersion matchVersion, Analyzer indexAnalyzer, IndexWriterConfig.OpenMode_e openMode) { IndexWriterConfig iwc = new IndexWriterConfig(matchVersion, indexAnalyzer); iwc.SetCodec(new Lucene46Codec()); iwc.SetOpenMode(openMode); // This way all merged segments will be sorted at // merge time, allow for per-segment early termination // when those segments are searched: iwc.SetMergePolicy(new SortingMergePolicy(iwc.MergePolicy, SORT)); return iwc; }
private static IndexWriter GetWriter(Directory directory) { MergePolicy policy = new LogByteSizeMergePolicy(); IndexWriterConfig conf = new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random())); conf.SetMergePolicy(policy); conf.SetOpenMode(OpenMode_e.CREATE_OR_APPEND); IndexWriter writer = new IndexWriter(directory, conf); return writer; }