中文亚洲精品无码_熟女乱子伦免费_人人超碰人人爱国产_亚洲熟妇女综合网

當(dāng)前位置: 首頁(yè) > news >正文

杭州公司展廳設(shè)計(jì)公司網(wǎng)站seo優(yōu)化分析

杭州公司展廳設(shè)計(jì)公司,網(wǎng)站seo優(yōu)化分析,大連做網(wǎng)站哪家公司好,坊子網(wǎng)站建設(shè)請(qǐng)確保已有可用的ES&#xff0c;若沒(méi)有&#xff0c;請(qǐng)移步&#xff1a;Docker安裝部署ElasticSearch&#xff08;ES&#xff09; 新建SpringBoot項(xiàng)目 這里是用的springboot版本是2.6.0 引入依賴 <!-- 排除springboot中內(nèi)置的es依賴,以防和easy-es中的依賴沖突--><…

請(qǐng)確保已有可用的ES,若沒(méi)有,請(qǐng)移步:Docker安裝部署ElasticSearch(ES)

新建SpringBoot項(xiàng)目

這里是用的springboot版本是2.6.0

引入依賴

<!-- 排除springboot中內(nèi)置的es依賴,以防和easy-es中的依賴沖突--><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId><exclusions><exclusion><groupId>org.elasticsearch.client</groupId><artifactId>elasticsearch-rest-high-level-client</artifactId></exclusion><exclusion><groupId>org.elasticsearch</groupId><artifactId>elasticsearch</artifactId></exclusion></exclusions></dependency><dependency><groupId>org.elasticsearch.client</groupId><artifactId>elasticsearch-rest-high-level-client</artifactId><version>7.14.0</version></dependency><dependency><groupId>org.elasticsearch</groupId><artifactId>elasticsearch</artifactId><version>7.14.0</version></dependency><dependency><groupId>cn.easy-es</groupId><artifactId>easy-es-boot-starter</artifactId><version>2.0.0-beta1</version></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><scope>test</scope></dependency>

配置文件

注意修改address信息,該為自己的ES地址

easy-es:enable: trueaddress : ES地址:9200global-config:process_index_mode: manual

項(xiàng)目結(jié)構(gòu)

listener部分我們先不用管
在這里插入圖片描述

啟動(dòng)類

添加掃描ESMapper的注解,指定路徑

@EsMapperScan("com.mine.easyEs.mapper")

在這里插入圖片描述

實(shí)體類

@Data
public class Document {@Id/*** es中的唯一id*/private String id;/*** 文檔標(biāo)題*/private String title;/*** 文檔內(nèi)容*/private String content;/*** 創(chuàng)建時(shí)間*/private Date createTime;
}

Controller類

包括對(duì)索引操作和對(duì)數(shù)據(jù)進(jìn)行操作的接口

@RestController
@RequestMapping("/ee")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class DocumentController {private final IDocumentService documentService;/*** 創(chuàng)建索引* @return 結(jié)果信息* @throws Exception*/@GetMapping("/createIndex")public String createIndex() throws Exception {return documentService.createIndex();}/*** 刪除索引* @return 結(jié)果信息*/@GetMapping("/deleteIndex")public String deleteIndex(){return documentService.deleteIndex();}/*** 查詢ES所有數(shù)據(jù)* @return 查詢Document結(jié)果對(duì)象集合*/@GetMapping("/findAll")public List<Document> findAll(){return documentService.findAllData();}/*** ES新增數(shù)據(jù)* @param document 新增數(shù)據(jù)對(duì)象* @return 結(jié)果信息* @throws Exception*/@GetMapping("/add")public String addData(Document document) throws Exception {return documentService.addData(document);}/*** 修改ES數(shù)據(jù)* @param document 修改數(shù)據(jù)對(duì)象*/@GetMapping("/update")public String updateData(Document document){return documentService.updateData(document);}/*** 根據(jù)id刪除ES數(shù)據(jù)* @param id 需要?jiǎng)h除的數(shù)據(jù)的id* @return*/@GetMapping("/delete")public String deleteData(String id){return documentService.deleteDataById(id);}/*** 分詞匹配查詢content字段* @param value 查詢內(nèi)容* @return*/@GetMapping("/match")public List<Document> findMatch(String value){return documentService.findMatch(value);}}

Mapper接口

繼承BaseMapper,整體操作都與MybatisPlus類似

public interface DocumentMapper extends BaseEsMapper<Document> {
}

Serice接口

public interface IDocumentService {/*** 查詢ES所有數(shù)據(jù)* @return 查詢Document結(jié)果對(duì)象集合*/List<Document> findAllData();/*** 創(chuàng)建索引* @return 結(jié)果信息* @throws Exception*/String createIndex() throws Exception;/*** 刪除索引* @return 結(jié)果信息*/String deleteIndex();/*** ES新增數(shù)據(jù)* @param document 新增數(shù)據(jù)實(shí)體類* @return 結(jié)果信息* @throws Exception*/String addData(Document document) throws Exception;/*** 根據(jù)id刪除ES數(shù)據(jù)* @param id 需要?jiǎng)h除的數(shù)據(jù)的id* @return*/String deleteDataById(String id);/*** 修改ES數(shù)據(jù)* @param document 修改數(shù)據(jù)對(duì)象*/String updateData(Document document);/*** 分詞匹配查詢content字段* @param value 查詢內(nèi)容* @return*/List<Document> findMatch(String value);
}

Service實(shí)現(xiàn)類

@Service
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class DocumentServiceImpl implements IDocumentService {private final DocumentMapper documentMapper;/*** 查詢ES所有數(shù)據(jù)* @return 查詢Document結(jié)果對(duì)象集合*/@Overridepublic List<Document> findAllData() {LambdaEsQueryWrapper<Document> wrapper = new LambdaEsQueryWrapper<>();wrapper.matchAllQuery();return documentMapper.selectList(wrapper);}/*** 創(chuàng)建索引* @return 結(jié)果信息* @throws Exception*/@Overridepublic String createIndex() throws Exception {StringBuilder msg = new StringBuilder();String indexName = Document.class.getSimpleName().toLowerCase();boolean existsIndex = documentMapper.existsIndex(indexName);if (existsIndex){throw new Exception("Document實(shí)體對(duì)應(yīng)索引已存在,刪除索引接口:deleteIndex");}boolean success = documentMapper.createIndex();if (success){msg.append("Document索引創(chuàng)建成功");}else {msg.append("索引創(chuàng)建失敗");}return msg.toString();}/*** 刪除索引* @return 結(jié)果信息*/@Overridepublic String deleteIndex() {StringBuilder msg = new StringBuilder();String indexName = Document.class.getSimpleName().toLowerCase();if (documentMapper.deleteIndex(indexName)){msg.append("刪除成功");}else {msg.append("刪除失敗");}return msg.toString();}/*** ES新增數(shù)據(jù)* @param document 新增數(shù)據(jù)實(shí)體類* @return 結(jié)果信息* @throws Exception*/@Overridepublic String addData(Document document) throws Exception {if (StringUtils.isEmpty(document.getTitle()) || StringUtils.isEmpty(document.getContent())) {throw new Exception("請(qǐng)補(bǔ)全title及content數(shù)據(jù)");}document.setCreateTime(new Date());documentMapper.insert(document);return "Added successfully!";}/*** 根據(jù)id刪除ES數(shù)據(jù)* @param id 需要?jiǎng)h除的數(shù)據(jù)的id* @return*/@Overridepublic String deleteDataById(String id) {documentMapper.deleteById(id);return "Success";}/*** 修改ES數(shù)據(jù)* @param document 修改數(shù)據(jù)對(duì)象*/@Overridepublic String updateData(Document document) {documentMapper.updateById(document);return "Success";}/*** 分詞匹配查詢content字段* @param value 查詢內(nèi)容* @return*/@Overridepublic List<Document> findMatch(String value) {LambdaEsQueryWrapper<Document> wrapper = new LambdaEsQueryWrapper<>();wrapper.match(Document::getContent,value);wrapper.orderByDesc(Document::getCreateTime);List<Document> documents = documentMapper.selectList(wrapper);return documents;}
}

啟動(dòng)、測(cè)試

使用PostMan測(cè)試

刪除索引

在這里插入圖片描述

創(chuàng)建索引

在這里插入圖片描述

添加數(shù)據(jù)

在這里插入圖片描述

查看所有數(shù)據(jù)

在這里插入圖片描述

修改數(shù)據(jù)

在這里插入圖片描述
在這里插入圖片描述

刪除數(shù)據(jù)

在這里插入圖片描述
在這里插入圖片描述

測(cè)試完成

http://www.risenshineclean.com/news/11090.html

相關(guān)文章:

  • 網(wǎng)站充值接口免費(fèi)推廣軟件
  • 網(wǎng)站建設(shè)需要域名服務(wù)器網(wǎng)絡(luò)營(yíng)銷手段有哪些方式
  • 網(wǎng)站手機(jī)app開(kāi)發(fā)seo引擎搜索入口
  • 如何做盆栽蔬菜網(wǎng)站網(wǎng)站首頁(yè)快速收錄
  • 哪些網(wǎng)站適合花錢(qián)做推廣朝陽(yáng)區(qū)seo技術(shù)
  • 巫山那家做網(wǎng)站厲害長(zhǎng)沙哪里有網(wǎng)站推廣優(yōu)化
  • 互助盤(pán)網(wǎng)站開(kāi)發(fā)杭州龍席網(wǎng)絡(luò)seo
  • wordpress 合法評(píng)論網(wǎng)站seo整站優(yōu)化
  • 網(wǎng)站建設(shè)平臺(tái)網(wǎng)站設(shè)計(jì)seo刷關(guān)鍵詞排名優(yōu)化
  • 慈溪高端網(wǎng)站設(shè)計(jì)百度貼吧怎么做推廣
  • 產(chǎn)品網(wǎng)站系統(tǒng)溫州最好的seo
  • 怎樣做網(wǎng)站的二維碼海豹直播nba
  • 完整的網(wǎng)站后臺(tái)權(quán)限編碼百度手機(jī)app
  • 怎么建手機(jī)網(wǎng)站鎮(zhèn)江關(guān)鍵字優(yōu)化公司
  • 用什么給網(wǎng)站做測(cè)試競(jìng)價(jià)惡意點(diǎn)擊犯法嗎
  • 搬瓦工512m內(nèi)存wordpress北京自動(dòng)seo
  • 沙田鎮(zhèn)做網(wǎng)站湖北seo診斷
  • 工信部 網(wǎng)站要獨(dú)立ip2023b站推廣大全
  • 速成網(wǎng)站-百度怎么推廣自己的視頻
  • 給公司申請(qǐng)網(wǎng)站用自己的賬號(hào)淮安百度推廣公司
  • .jsp網(wǎng)站開(kāi)發(fā)技術(shù)疫情排行榜最新消息
  • 網(wǎng)站欄目變了怎么做跳轉(zhuǎn)競(jìng)價(jià)托管推廣公司
  • 網(wǎng)站推廣及seo方案網(wǎng)站怎么進(jìn)入
  • 網(wǎng)站建設(shè)課程設(shè)計(jì)sem托管公司
  • 做網(wǎng)站的畢業(yè)論文怎么寫(xiě)網(wǎng)絡(luò)廣告營(yíng)銷典型案例
  • 攝影師的網(wǎng)站有哪些深圳百度seo代理
  • 互聯(lián)網(wǎng)站備案seo關(guān)鍵詞排名優(yōu)化案例
  • 有一個(gè)做場(chǎng)景動(dòng)畫(huà)的網(wǎng)站怎么提交百度收錄
  • 蘇州知名高端網(wǎng)站建設(shè)網(wǎng)絡(luò)公司上海seo優(yōu)化外包公司
  • 做網(wǎng)站語(yǔ)言最好梅州seo