1. 配置
2. 目录
提供的文件目录结构
ms-elasticsearch:基于es的搜索插件,
ms-mcms:提供了默认的文章es搜索,直接将ms-mcms下的src代码合并覆盖到当前开发项目
2.1. application.yml
必须先安装环境,ip根据实际情况编写
spring:
elasticsearch:
rest:
uris: http://ip:9200
2.2. pom.xml
依赖ms-elasticsearch的方式
方式1、将ms-elasticsearch打包成jar, 同步到本地的maven库;
方式2、直接将ms-elasticsearch源代码复制到项目中
<dependency>
<groupId>net.mingsoft</groupId>
<artifactId>ms-elasticsearch</artifactId>
<version>1.0.0</version>
</dependency>
2.3. 搜索接口
请求地址
/cms/es/search/highlightSearch.do
swagger参考
http://ip:8080/swagger-ui.html#/es-search-action
请求参数
keyword: 国内
order: desc
orderby: date
pageSize: 10
pageNo: 1
title: 国内
返回值
{
"result": true,
"code": 200,
"data": {
"total": 1,
"rows": [ //记录列表
{
"contentKeyword": "<span style='color:red'>国</span><span style='color:red'>内</span>ms",
"sort": 0,
"id": "1346299650146922497",
"title": "[【网站】<span style='color:red'>国</span><span style='color:red'>内</span> 前6名 Java开源CMS建站系统]",
"content": "[下面我们开始分享一下开源中<span style='color:red'>国</span>中最火的Java开源CMS建站系统]",
"typeId": "1392359380113481730",
"parentIds": "1382233650262241282",
"date": "2017-08-29 20:04:31",
"author" : "",
"net" : "1",
"typeId" : "1458331507951800321",
"litPic" : """[{"url":"blob:http://192.168.0.118:8080/5e548893-1b5f-46cd-8193-fc7c48b2cc7f","name":"1637824298771.jpg","path":"/upload/1/cms/content/1637906304084.jpg","uid":1637906304036,"status":"success"}]""",
"typeTitle" : "早间新闻",
"flag" : "c",
"type" : "content",
"descrip": "-",
"url" : """/xinwen/zaojianxinwen\c1458332611057946626.html"""
}
]
}
}