🐛 IORuntimeException: Path [lucene/index/xxx] is not directory!
This commit is contained in:
parent
741e7fb4fe
commit
b1ac559f39
@ -1,6 +1,7 @@
|
|||||||
package com.rymcu.forest.lucene.util;
|
package com.rymcu.forest.lucene.util;
|
||||||
|
|
||||||
import cn.hutool.core.io.FileUtil;
|
import cn.hutool.core.io.FileUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.rymcu.forest.lucene.model.ArticleLucene;
|
import com.rymcu.forest.lucene.model.ArticleLucene;
|
||||||
import org.apache.lucene.document.Document;
|
import org.apache.lucene.document.Document;
|
||||||
import org.apache.lucene.document.Field;
|
import org.apache.lucene.document.Field;
|
||||||
@ -23,8 +24,7 @@ public class ArticleIndexUtil {
|
|||||||
/**
|
/**
|
||||||
* lucene索引保存目录
|
* lucene索引保存目录
|
||||||
*/
|
*/
|
||||||
private static final String PATH =
|
private static final String PATH = System.getProperty("user.dir") + StrUtil.SLASH + LucenePath.ARTICLE_INDEX_PATH;
|
||||||
LucenePath.ARTICLE_INDEX_PATH;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除所有运行中保存的索引
|
* 删除所有运行中保存的索引
|
||||||
|
@ -23,7 +23,7 @@ public class PortfolioIndexUtil {
|
|||||||
/**
|
/**
|
||||||
* lucene索引保存目录
|
* 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 {
|
try {
|
||||||
writer = IndexUtil.getIndexWriter(each.getAbsolutePath(), false);
|
writer = IndexUtil.getIndexWriter(each.getAbsolutePath(), false);
|
||||||
writer.deleteDocuments(new Term("id", String.valueOf(id)));
|
writer.deleteDocuments(new Term("id", String.valueOf(id)));
|
||||||
|
writer.forceMerge(1);
|
||||||
writer.forceMergeDeletes(); // 强制删除
|
writer.forceMergeDeletes(); // 强制删除
|
||||||
writer.commit();
|
writer.commit();
|
||||||
writer.close();
|
writer.close();
|
||||||
|
@ -25,7 +25,7 @@ public class UserIndexUtil {
|
|||||||
/**
|
/**
|
||||||
* lucene索引保存目录
|
* 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 {
|
try {
|
||||||
writer = IndexUtil.getIndexWriter(each.getAbsolutePath(), false);
|
writer = IndexUtil.getIndexWriter(each.getAbsolutePath(), false);
|
||||||
writer.deleteDocuments(new Term("id", id));
|
writer.deleteDocuments(new Term("id", id));
|
||||||
|
writer.forceMerge(1);
|
||||||
writer.forceMergeDeletes(); // 强制删除
|
writer.forceMergeDeletes(); // 强制删除
|
||||||
writer.commit();
|
writer.commit();
|
||||||
writer.close();
|
writer.close();
|
||||||
|
Loading…
Reference in New Issue
Block a user