🎨 搜索结果展示效果优化

This commit is contained in:
ronger 2021-06-02 21:47:13 +08:00
parent 60d3380758
commit ce1767ac3f
2 changed files with 154 additions and 148 deletions

View File

@ -9,6 +9,7 @@ import com.rymcu.forest.lucene.service.LuceneService;
import com.rymcu.forest.lucene.util.ArticleIndexUtil; import com.rymcu.forest.lucene.util.ArticleIndexUtil;
import com.rymcu.forest.lucene.util.LucenePath; import com.rymcu.forest.lucene.util.LucenePath;
import com.rymcu.forest.lucene.util.SearchUtil; import com.rymcu.forest.lucene.util.SearchUtil;
import com.rymcu.forest.util.Html2TextUtil;
import org.apache.lucene.analysis.Analyzer; import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.TokenStream; import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.document.Document; import org.apache.lucene.document.Document;
@ -41,7 +42,8 @@ import java.util.concurrent.Executors;
@Service @Service
public class LuceneServiceImpl implements LuceneService { public class LuceneServiceImpl implements LuceneService {
@Resource private ArticleLuceneMapper luceneMapper; @Resource
private ArticleLuceneMapper luceneMapper;
/** /**
* 将文章的数据解析为一个个关键字词存储到索引文件中 * 将文章的数据解析为一个个关键字词存储到索引文件中
@ -187,7 +189,11 @@ public class LuceneServiceImpl implements LuceneService {
@Override @Override
public List<ArticleLucene> getAllArticleLucene() { public List<ArticleLucene> getAllArticleLucene() {
return luceneMapper.getAllArticleLucene(); List<ArticleLucene> list = luceneMapper.getAllArticleLucene();
for (ArticleLucene articleLucene : list) {
articleLucene.setArticleContent(Html2TextUtil.getContent(articleLucene.getArticleContent()));
}
return list;
} }
@Override @Override

View File

@ -32,7 +32,7 @@
<result column="article_sponsor_count" property="articleSponsorCount"></result> <result column="article_sponsor_count" property="articleSponsorCount"></result>
</resultMap> </resultMap>
<select id="getAllArticleLucene" resultMap="ResultMapWithBLOBs"> <select id="getAllArticleLucene" resultMap="ResultMapWithBLOBs">
select art.id, art.article_title, content.article_content select art.id, art.article_title, content.article_content_html as article_content
from forest_article art from forest_article art
join forest_article_content content on art.id = content.id_article join forest_article_content content on art.id = content.id_article
where article_status = 0; where article_status = 0;