简体   繁体   中英

Lucene.net, Error indexing a document with Filed.Store.COMPRESS

I'm developing a index, and need to store values compressed, because its needed to show that info to the user. I've the current error: "Can not load ICSharpCode.SharpZipLib.dll", when I do the writer.AddDocument(doc);

The DLLs are from NuGet, and I've the SharpZipLib because is a dependecy of Lucene.net.

Snippet:

System.IO.DirectoryInfo directoryInfo = new System.IO.DirectoryInfo(path);  
Directory directory = FSDirectory.Open(directoryInfo);  
Analyzer analyzer = new SnowballAnalyzer("Portuguese");  
bool isNew = !IndexReader.IndexExists(directory);  
IndexWriter writer = new IndexWriter(directory, analyzer, isNew, Lucene.Net.Index.IndexWriter.MaxFieldLength.UNLIMITED);  
//Create document  
Document doc = new Document();  
NumericField numericField = new NumericField("id", Field.Store.YES, false);  
numericField.SetIntValue(id);  
doc.Add(numericField);  
Field field = new Field("title", title, Field.Store.COMPRESS, Field.Index.ANALYZED);  
field.SetBoost(7);  
doc.Add(field);  
field = new Field("description", tescription, Field.Store.COMPRESS, Field.Index.ANALYZED);  
doc.Add(field);  
writer.AddDocument(doc);  
writer.Optimize();  
//Close the writer  
writer.Commit();  
writer.Close();  
}  
catch (Exception ex)  
{ throw ex; }

Thanks in advance

That means lucene cannot find the SharpZipLib DLL in your build path, make sure it is copied to the output of your project

Note that compressed fields are deprecated in recent versions of Lucene, I would not recommend to use them. You should use the CompressionTools class instead, or roll out your own compression methods.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM