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

This commit is contained in:
ronger 2023-01-06 15:06:57 +08:00
parent 741e7fb4fe
commit b1ac559f39
3 changed files with 6 additions and 4 deletions

View File

@ -1,6 +1,7 @@
package com.rymcu.forest.lucene.util;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.StrUtil;
import com.rymcu.forest.lucene.model.ArticleLucene;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
@ -23,8 +24,7 @@ public class ArticleIndexUtil {
/**
* lucene索引保存目录
*/
private static final String PATH =
LucenePath.ARTICLE_INDEX_PATH;
private static final String PATH = System.getProperty("user.dir") + StrUtil.SLASH + LucenePath.ARTICLE_INDEX_PATH;
/**
* 删除所有运行中保存的索引

View File

@ -23,7 +23,7 @@ public class PortfolioIndexUtil {
/**
* lucene索引保存目录
*/
private static final String PATH = LucenePath.PORTFOLIO_PATH;
private static final String PATH = System.getProperty("user.dir") + StrUtil.SLASH + LucenePath.PORTFOLIO_PATH;
/**
* 删除所有运行中保存的索引
@ -81,6 +81,7 @@ public class PortfolioIndexUtil {
try {
writer = IndexUtil.getIndexWriter(each.getAbsolutePath(), false);
writer.deleteDocuments(new Term("id", String.valueOf(id)));
writer.forceMerge(1);
writer.forceMergeDeletes(); // 强制删除
writer.commit();
writer.close();

View File

@ -25,7 +25,7 @@ public class UserIndexUtil {
/**
* lucene索引保存目录
*/
private static final String PATH = LucenePath.USER_PATH;
private static final String PATH = System.getProperty("user.dir") + StrUtil.SLASH + LucenePath.USER_PATH;
/**
* 系统运行时索引保存目录
@ -89,6 +89,7 @@ public class UserIndexUtil {
try {
writer = IndexUtil.getIndexWriter(each.getAbsolutePath(), false);
writer.deleteDocuments(new Term("id", id));
writer.forceMerge(1);
writer.forceMergeDeletes(); // 强制删除
writer.commit();
writer.close();