protected void AddDocumentToIndex(RavenIndexWriter currentIndexWriter, Document luceneDoc, Analyzer analyzer) { Analyzer newAnalyzer = AnalyzerGenerators.Aggregate(analyzer, (currentAnalyzer, generator) => { Analyzer generateAnalyzer = generator.Value.GenerateAnalyzerForIndexing(name, luceneDoc, currentAnalyzer); if (generateAnalyzer != currentAnalyzer && currentAnalyzer != analyzer) currentAnalyzer.Close(); return generateAnalyzer; }); try { if (indexExtensions.Count > 0) currentlyIndexDocuments.Add(CloneDocument(luceneDoc)); currentIndexWriter.AddDocument(luceneDoc, newAnalyzer); foreach (var fieldable in luceneDoc.GetFields()) { using (fieldable.ReaderValue) // dispose all the readers { } } } finally { if (newAnalyzer != analyzer) newAnalyzer.Close(); } }
protected void AddDocumentToIndex(RavenIndexWriter currentIndexWriter, Document luceneDoc, Analyzer analyzer) { Analyzer newAnalyzer = AnalyzerGenerators.Aggregate(analyzer, (currentAnalyzer, generator) => { Analyzer generateAnalyzer = generator.Value.GenerateAnalyzerForIndexing(name, luceneDoc, currentAnalyzer); if (generateAnalyzer != currentAnalyzer && currentAnalyzer != analyzer) currentAnalyzer.Close(); return generateAnalyzer; }); try { if (indexExtensions.Count > 0) currentlyIndexDocuments.Add(CloneDocument(luceneDoc)); currentIndexWriter.AddDocument(luceneDoc, newAnalyzer); } finally { if (newAnalyzer != analyzer) newAnalyzer.Close(); } }