当前位置: 首页 > news >正文

网页源代码提取文件西安自动seo

网页源代码提取文件,西安自动seo,关于拳馆网站建设计划书,高端网站建设信息个人名片: 博主:酒徒ᝰ. 个人简介:沉醉在酒中,借着一股酒劲,去拼搏一个未来。 本篇励志:三人行,必有我师焉。 本项目基于B站黑马程序员Java《SpringCloud微服务技术栈》,SpringCloud…

请添加图片描述
个人名片:

博主:酒徒ᝰ.
个人简介沉醉在酒中,借着一股酒劲,去拼搏一个未来。
本篇励志三人行,必有我师焉。

请添加图片描述
本项目基于B站黑马程序员Java《SpringCloud微服务技术栈》,SpringCloud+RabbitMQ+Docker+Redis+搜索+分布式

【SpringCloud+RabbitMQ+Docker+Redis+搜索+分布式,系统详解springcloud微服务技术栈课程|黑马程序员Java微服务】 点击观看

目录

  • 四、RestAPI

四、RestAPI

ES官方提供了各种不同语言的客户端,用来操作ES。
这些客户端的本质就是组装DSL语句,通过http请求发送给ES。
官方文档地址:https://www.elastic.co/guide/en/elasticsearch/client/index.html

案例:利用JavaRestClient实现创建、删除索引库,判断索引库是否存在

  1. 准备工程
    导入项目
    导入mysql数据
    修改application.yaml中的url和password,改为自己数据库的位置和密码
  2. 创建索引库
    导入es依赖
<dependency><groupId>org.elasticsearch.client</groupId><artifactId>elasticsearch-rest-high-level-client</artifactId>
</dependency>

更改es版本为我们当前使用的版本

<properties><elasticsearch.version>7.12.1</elasticsearch.version>
</properties>

初始化代码

public class HotelIndexTest {private RestHighLevelClient client;@BeforeEachvoid setUp() {this.client = new RestHighLevelClient(RestClient.builder(HttpHost.create("http://192.168.179.128:9200")));}@AfterEachvoid tearDown() throws IOException {this.client.close();}
}

建立DSL的JSON参数部分

package cn.itcast.hotel;public class HotelConstants {public static final String MAPPING_TEMPLATE = "{\n" +"  \"mappings\": {\n" +"    \"properties\": {\n" +"      \"id\": {\n" +"        \"type\": \"keyword\"\n" +"      },\n" +"      \"name\": {\n" +"        \"type\": \"text\",\n" +"        \"analyzer\": \"ik_max_word\",\n" +"        \"copy_to\": \"all\"\n" +"      },\n" +"      \"address\": {\n" +"        \"type\": \"keyword\",\n" +"        \"index\": false\n" +"      },\n" +"      \"price\": {\n" +"        \"type\": \"integer\"\n" +"      },\n" +"      \"score\": {\n" +"        \"type\": \"integer\"\n" +"      },\n" +"      \"brand\": {\n" +"        \"type\": \"keyword\",\n" +"        \"copy_to\": \"all\"\n" +"      },\n" +"      \"city\": {\n" +"        \"type\": \"keyword\"\n" +"      },\n" +"      \"starName\": {\n" +"        \"type\": \"keyword\"\n" +"      },\n" +"      \"business\": {\n" +"        \"type\": \"keyword\",\n" +"        \"copy_to\": \"all\"\n" +"      },\n" +"      \"location\": {\n" +"        \"type\": \"geo_point\"\n" +"      },\n" +"      \"pic\": {\n" +"        \"type\": \"keyword\",\n" +"        \"index\": false\n" +"      },\n" +"      \"all\": {\n" +"        \"type\": \"text\",\n" +"        \"index\": true,\n" +"        \"analyzer\": \"ik_max_word\"\n" +"      }\n" +"    }\n" +"  }\n" +"}";
}

发送请求

@Test
void testCreateHotelIndex() throws IOException {CreateIndexRequest request = new CreateIndexRequest("hotel");request.source(MAPPING_TEMPLATE, XContentType.JSON);client.indices().create(request, RequestOptions.DEFAULT);
}
  1. 删除索引库
@Test
void testDeleteHotelIndex() throws IOException {DeleteIndexRequest request = new DeleteIndexRequest("hotel");client.indices().delete(request, RequestOptions.DEFAULT);
}
  1. 判断索引库是否存在
@Test
void testExitsHotelIndex() throws IOException {GetIndexRequest request = new GetIndexRequest("hotel");boolean exists = client.indices().exists(request, RequestOptions.DEFAULT);System.out.println(exists);
}

总结:

JavaRestClient操作elasticsearch的流程基本类似。
核心是client.indices()方法来获取索引库的操作对象。
索引库操作的基本步骤:
初始化RestHighLevelClient
创建XxxIndexRequest。XXX是Create、Get、Delete
准备DSL( Create时需要,其它是无参)
发送请求。调用RestHighLevelClient#indices().xxx()方法,xxx是create、exists、delete

http://www.mmbaike.com/news/103646.html

相关文章:

  • 模板价格360优化大师下载安装
  • 用jsp做的可运行的网站百度网讯科技有限公司官网
  • 惠州网站搭建找谁百度代理查询系统
  • 网站权重能带来什么作用做网站的公司哪家最好
  • 台州做网站的公司百度退款客服电话
  • 网站的设计电商网站设计方案
  • 印团网网站是哪家做的网络广告类型
  • 国外做饰品批发网站seo技术培训中心
  • 徐州网站建设魔站培训机构是干什么的
  • linux建设视频网站最近一周国内热点新闻
  • 照片制作视频软件搜索引擎营销seo
  • 凡客诚品特色网站的优化从哪里进行
  • 免费看电视的网站全球新闻最新消息
  • 做网站的最大的挑战是什么怎么才能在百度上做引流呢
  • 网站建站管理系统百度搜索风云榜游戏
  • 潍坊知名网站建设怎么收费上海知名seo公司
  • 哪里有做网站优化的公司营销方式和渠道
  • 公司网站制作平台网站工具查询
  • wordpress免登录发布接口广州网络seo优化
  • c 做网站源码实例抖音seo优化
  • 京东网上商城跟京东是一家吗谷歌seo网站推广
  • 单页面网站做百度推广站长工具高清
  • 网站主题旁边的图标怎么做的500个游戏推广群
  • wordpress是建站最快的长沙seo计费管理
  • 网站建设合作流程图万网域名购买
  • 犀牛建筑网校九幺seo工具
  • 建站收费标准社会新闻最新消息
  • 文本文档做网站搜狗关键词优化软件
  • asp网站后台失效十八未成年禁用免费app
  • wordpress网站菜单固定seo网站排名优化培训教程