🐛 IORuntimeException: Path [lucene/index/xxx] is not directory!

This commit is contained in:
ronger 2023-01-06 14:32:24 +08:00
parent d9d9a29bb3
commit 741e7fb4fe
2 changed files with 10 additions and 2 deletions

View File

@ -53,7 +53,11 @@ public class PortfolioIndexUtil {
System.out.println("创建单个索引");
IndexWriter writer;
try {
writer = IndexUtil.getIndexWriter(LucenePath.PORTFOLIO_INCREMENT_INDEX_PATH, false);
boolean create = true;
if (FileUtil.exist(LucenePath.PORTFOLIO_INCREMENT_INDEX_PATH)) {
create = false;
}
writer = IndexUtil.getIndexWriter(LucenePath.PORTFOLIO_INCREMENT_INDEX_PATH, create);
Document doc = new Document();
doc.add(new StringField("id", t.getIdPortfolio() + "", Field.Store.YES));
doc.add(new TextField("title", t.getPortfolioTitle(), Field.Store.YES));

View File

@ -60,7 +60,11 @@ public class UserIndexUtil {
System.out.println("创建单个索引");
IndexWriter writer;
try {
writer = IndexUtil.getIndexWriter(INDEX_PATH, false);
boolean create = true;
if (FileUtil.exist(LucenePath.USER_INCREMENT_INDEX_PATH)) {
create = false;
}
writer = IndexUtil.getIndexWriter(INDEX_PATH, create);
Document doc = new Document();
doc.add(new StringField("id", t.getIdUser() + "", Field.Store.YES));
doc.add(new TextField("nickname", t.getNickname(), Field.Store.YES));