💩 修复articleLucene查询错误
- 增加luceneArticle增加更新接口
This commit is contained in:
parent
03c8e339df
commit
96739bf1cf
@ -83,7 +83,8 @@ public class LuceneServiceImpl implements LuceneService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeArticle(String id) throws Exception {
|
public void writeArticle(String id) throws Exception {
|
||||||
writeArticle(luceneMapper.getById(id), true);
|
// TODO 做新增或更新判断
|
||||||
|
writeArticle(luceneMapper.getById(id), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -92,20 +93,30 @@ public class LuceneServiceImpl implements LuceneService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteArticle(String id) {}
|
public void deleteArticle(String id) {
|
||||||
|
try {
|
||||||
|
deleteIndex(id);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void writeArticle(ArticleLucene article, boolean create) throws Exception {
|
private void writeArticle(ArticleLucene article, boolean create) throws Exception {
|
||||||
if (!create) {
|
if (!create) {
|
||||||
int size = Objects.requireNonNull(new File(indexPath).listFiles()).length;
|
deleteIndex(article.getIdArticle());
|
||||||
while (size-- >= 0) {
|
|
||||||
ArticleBeanIndex index = new ArticleBeanIndex(indexPath, size);
|
|
||||||
index.deleteDoc(article.getIdArticle());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
ArticleBeanIndex index = new ArticleBeanIndex(indexPath, 0x0);
|
ArticleBeanIndex index = new ArticleBeanIndex(indexPath, 777);
|
||||||
index.indexDoc(article);
|
index.indexDoc(article);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void deleteIndex(String id) throws IOException {
|
||||||
|
int size = Objects.requireNonNull(new File(indexPath).listFiles()).length;
|
||||||
|
while (size-- >= 0) {
|
||||||
|
ArticleBeanIndex index = new ArticleBeanIndex(indexPath, size);
|
||||||
|
index.deleteDoc(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 关键词搜索
|
* 关键词搜索
|
||||||
*
|
*
|
||||||
|
@ -62,7 +62,7 @@
|
|||||||
</foreach>
|
</foreach>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="getById" resultMap="DTOResultMap">
|
<select id="getById" resultMap="ResultMapWithBLOBs">
|
||||||
select art.id, art.article_title, content.article_content
|
select art.id, art.article_title, content.article_content
|
||||||
from forest_article art
|
from forest_article art
|
||||||
left join forest_article_content content on art.id = content.id_article
|
left join forest_article_content content on art.id = content.id_article
|
||||||
|
Loading…
Reference in New Issue
Block a user