internal static IndexWriter CreateIndexWriter(Lucene.Net.Store.Directory directory) { bool create = !IndexReader.IndexExists(directory); directory.EnsureOpen(); if (!create) { if (IndexWriter.IsLocked(directory)) { IndexWriter.Unlock(directory); } } IndexWriter indexWriter = new IndexWriter(directory, new PackageAnalyzer(), create, IndexWriter.MaxFieldLength.UNLIMITED); indexWriter.MergeFactor = MergeFactor; indexWriter.MaxMergeDocs = MaxMergeDocs; indexWriter.SetSimilarity(new CustomSimilarity()); return indexWriter; }
private static IndexWriter CreateIndexWriter(Lucene.Net.Store.Directory directory) { var create = !IndexReader.IndexExists(directory); directory.EnsureOpen(); if (!create) { if (IndexWriter.IsLocked(directory)) { IndexWriter.Unlock(directory); } } var indexWriter = new IndexWriter(directory, new PackageAnalyzer(), create, IndexWriter.MaxFieldLength.UNLIMITED); NuGetMergePolicyApplyer.ApplyTo(indexWriter); indexWriter.SetSimilarity(new CustomSimilarity()); return indexWriter; }