Lucene 인덱스를 약 5000 개의 문서로 만들려고하는데 생성되는 인덱스가 너무 커지는 것 같습니다. 색인의 크기를 줄이는 방법이 있는지 알고 싶습니다.Lucene 인덱스 크기가 너무 큽니다.
Lucene 4.10을 사용하고 있으며 색인을 생성하려는 문서는 다양한 형식 (.docx, .xlsx, .pdf, .rtf, .txt)입니다. 인덱싱 할 문서가 들어있는 디렉토리의 크기는 약 1Gb입니다. 3000/5000 문서를 인덱싱 한 후 인덱스 크기는 이미 10Gb입니다. 디렉토리 크기가 인덱스 크기에 비해 정상적인 비율에 대한 유용한 정보를 찾지 못했지만 10Gb 인덱스는 1Gb의 문서에 비해 너무 큰 것처럼 보입니다.
문서를 읽으려면 Tika 1.6 AutoDetectParser를 사용하여 각 문서의 내용이 포함 된 문자열을 생성합니다.
다음 스 니펫은 색인을 작성하는 방법을 보여줍니다. 인덱스 작가를 만든 후, 그것은 방법 walkFiles()를 호출 각 문서 읽기 (는 "DocReader"클래스를 사용) 및 인덱스에 추가 문서 디렉토리를 통과하기 : 내가
public void indexDocs() {
docDir = "C:/MyDocDir";
indexPath = "C:/DocIndex";
docIndexDir = FSDirectory.open(new File(indexPath));
analysis = new StopAnalyzer();
iwc = new IndexWriterConfig(Version.LUCENE_4_10_0, analysis);
iwc.setOpenMode(OpenMode.CREATE);
docIndex = new IndexWriter(docIndexDir, iwc);
addDoc = new Document();
walkFiles(docDir);
docIndex.close();
}
private void walkFiles(String docDir) {
File docRoot = new File(docDir);
File[] list = docRoot.listFiles();
if (list == null) return;
for (File f : list) {
if (f.isDirectory()) {
walkFiles(f.getAbsolutePath());
}
else {
String docName = f.getAbsolutePath();
DocReader readDoc = new DocReader(docName);
if (readDoc.readFile()) {
String docPath = readDoc.getPath();
String docText = readDoc.getText();
Field pathField = new StringField("path", docPath, Field.Store.NO);
Field contentField = new TextField("contents", docText, Field.Store.NO);
addDoc.add(pathField);
addDoc.add(contentField);
docIndex.addDocument(addDoc);
}
}
}
}
공지 사항 StopAnalyzer를 사용하고 Field.Store.NO 매개 변수를 사용하여 contents Field를 작성하십시오. 색인 크기를 줄이는 데 도움이되는 많은 정보를 찾을 수 없습니다. 또한 인덱스가 얼마나 큰지에 대한 실제 수치를 가진 사람이 인덱스중인 문서의 총 크기와 비교되는지 알고 싶습니다.
네, 그게 문제였습니다. 도와 주셔서 감사합니다! – linuxguru