我正在使用apache lucene爲日誌文件創建文本搜索應用程序。我使用的波紋管代碼索引Apache lucene索引
doc.add(new LongField("modified", file.lastModified(), Field.Store.NO));
doc.add(new TextField("contents", new BufferedReader(new InputStreamReader(fis, "UTF-8"))));
doc.add(new StoredField("filename", file.getCanonicalPath()));
我在這裏創建爲每個文件3個索引文件,但搜索我只能檢索一個索引值另外兩個都爲空時。這是搜索端代碼
Document d = searcher.doc(docId);
System.out.println(i+":File name is"+d.get("filename"));
System.out.println(i+":File name is"+d.get("modified"));
System.out.println(i+":File name is"+d.get("contents"));
我得到的輸出是
2 total matching documents
0:File name is/home/maclean/NetBeansProjects/LogSearchEngine/src/SimpleSearcher.java
0:File name isnull
0:File name isnull
1:File name is/home/maclean/NetBeansProjects/LogSearchEngine/src/SimpleFileIndexer.java
1:File name isnull
1:File name isnull
我在做什麼錯
使用Field.Store.YES而不是Field.Store.NO – vikasing 2013-03-08 12:41:24