Lucene学习笔记--创建FS索引(FSDirectory)
public void FSDirectoryCreateIndex() { try { File file = new File(FILE_PATH); Directory directory = FSDirectory.getDirectory(INDEX_STORE_PATH); Document doc = new Document(); IndexWriter indexWriter = new IndexWriter(directory, analyzer, true, MaxFieldLength.LIMITED); Field field = new Field("content", loadFileToString(file), Field.Store.NO, Field.Index.TOKENIZED); doc.add(field); field = new Field("name", file.getName(), Field.Store.YES, Field.Index.TOKENIZED); doc.add(field); field = new Field("path", file.getPath(), Field.Store.YES, Field.Index.TOKENIZED); doc.add(field); indexWriter.addDocument(doc); indexWriter.close(); } catch (Exception e) { e.printStackTrace(); } }
相关推荐
ribavnu 2020-11-16
moyekongling 2020-11-13
坚持是一种品质 2020-11-16
chenjiazhu 2020-09-29
kikaylee 2020-10-31
Ida 2020-09-16
liuweiq 2020-09-09
silencehgt 2020-09-07
sunnyxuebuhui 2020-09-07
西瓜皮儿的皮儿 2020-09-07
LuckyLXG 2020-09-08
明瞳 2020-08-19
MissFuTT 2020-08-18
jzlixiao 2020-08-18
zhushenghan 2020-08-16
罗罗 2020-08-16
mrandy 2020-08-15
houdaxiami 2020-08-15