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

html做网站的原则微信公众号营销

html做网站的原则,微信公众号营销,网站做阿拉伯语的,jsp新闻网站开发框架一 SpringBoot Elasticsearch 项目环境搭建 1.1 修改pom文件添加依赖 目前使用spring-boot-starter-parent版本为2.2.8.RELEASE 对应spring-data-elasticsearch版本为2.2.8.RELEASE,版本对应可以自行百度,如果不行直接用elasticsearch-rest-high-lev…

一 SpringBoot + Elasticsearch 项目环境搭建

1.1 修改pom文件添加依赖

目前使用spring-boot-starter-parent版本为2.2.8.RELEASE

对应spring-data-elasticsearch版本为2.2.8.RELEASE,版本对应可以自行百度,如果不行直接用elasticsearch-rest-high-level-client工具类吧

      <dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-data-elasticsearch</artifactId><version>2.2.8.RELEASE</version></dependency><dependency><groupId>org.elasticsearch</groupId><artifactId>elasticsearch</artifactId><version>7.5.0</version></dependency><dependency><groupId>org.elasticsearch.client</groupId><artifactId>elasticsearch-rest-client</artifactId><version>7.5.0</version></dependency><dependency><groupId>org.elasticsearch.client</groupId><artifactId>elasticsearch-rest-high-level-client</artifactId><version>7.5.0</version></dependency>
1.2 新建配置文件
import org.apache.http.HttpHost;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;/*** ES配置类** @author lc* @version 1.0* @date 2022/3/25 10:53*/
@Configuration
public class ElasticSearchClientConfig {@Beanpublic RestHighLevelClient restHighLevelClient() {RestHighLevelClient client = new RestHighLevelClient(RestClient.builder(new HttpHost("192.168.1.100", 9200, "http")));return client;}
}

二 RestHighLevelClient的使用

RestHighLevelClient是Elasticsearch 的操作方法,我们先进行引用吧。

@Autowired
private RestHighLevelClient client;

1、创建索引

 @Testvoid testCreateIndex() throws IOException {//1 创建索引请求CreateIndexRequest request = new CreateIndexRequest("zlc_index");//2 客户端执行请求CreateIndexResponse createIndexResponse =client.indices().create(request, RequestOptions.DEFAULT);System.out.println(createIndexResponse);}

2、索引是否存在

@Testvoid testExistIndex() throws IOException {GetIndexRequest request = new GetIndexRequest("zlc_index");boolean exists = client.indices().exists(request, RequestOptions.DEFAULT);System.out.println(exists);}

3、删除索引

@Testvoid testDeleteIndex() throws IOException {DeleteIndexRequest request = new DeleteIndexRequest("zlc_index");AcknowledgedResponse delete = client.indices().delete(request, RequestOptions.DEFAULT);System.out.println(delete.isAcknowledged());}

4、添加文档

@Testvoid testAddDocument() throws IOException {//创建对象UserES user = new UserES();user.setUserName("suwerw");user.setUserPhone("178245774");//创建请求IndexRequest request = new IndexRequest("zlc_index");//规则 put /zlc_index/_doc/1request.id("1");request.timeout(TimeValue.timeValueSeconds(1));request.timeout("1s");//将数据放入请求request.source(JSON.toJSONString(user), XContentType.JSON);//客户端发送请求,获取响应结果IndexResponse indexResponse = client.index(request, RequestOptions.DEFAULT);System.out.println(indexResponse.toString());System.out.println(indexResponse.status());}

5、判断文档是否存在

@Testvoid testIsExists() throws IOException {GetRequest getRequest = new GetRequest("zlc_index", "1");//不获取返回的 _source 的上下文,提高效率getRequest.fetchSourceContext(new FetchSourceContext(false));getRequest.storedFields("_none_");boolean exists = client.exists(getRequest, RequestOptions.DEFAULT);System.out.println(exists);}

6、获取文档

 @Testvoid testGetDocument() throws IOException {GetRequest getRequest = new GetRequest("zlc_index", "1");GetResponse getResponse = client.get(getRequest, RequestOptions.DEFAULT);System.out.println(getResponse);System.out.println(getResponse.getSourceAsString());}

7、更新文档信息

 @Testvoid testUpdateDocument() throws IOException {UpdateRequest updateRequest = new UpdateRequest("zlc_index", "1");updateRequest.timeout("1s");UserES user = new UserES();user.setUserName("Zhou_LC");user.setUserPhone("233669");updateRequest.doc(JSON.toJSONString(user), XContentType.JSON);UpdateResponse updateResponse = client.update(updateRequest, RequestOptions.DEFAULT);System.out.println(updateResponse);System.out.println(updateResponse.status());}

8、删除文档

  @Testvoid testDeleteDocument() throws IOException {DeleteRequest deleteRequest = new DeleteRequest("zlc_index", "1");deleteRequest.timeout("1s");DeleteResponse deleteResponse = client.delete(deleteRequest, RequestOptions.DEFAULT);System.out.println(deleteResponse);System.out.println(deleteResponse.status());}
http://www.hkea.cn/news/357378/

相关文章:

  • 岳阳做网站怎么做推广让别人主动加我
  • 不断改进网站建设公司百度官网优化
  • 万户网站宁波网站制作优化服务
  • 潍坊快速网站排名网站是怎么做出来的
  • 聚美优品的pc网站建设注册网址
  • 陕西省住房与城乡建设厅网站免费b站推广软件
  • 淮南市住房与城乡建设部网站网店买卖有哪些平台
  • 网页qq表情佛山百度快速排名优化
  • 网站建设方案论文1500社会新闻最新消息
  • 网站组建 需求分析市场监督管理局职责
  • 云课堂哪个网站做的好厦门关键词优化seo
  • 中企动力沈阳分公司seo免费诊断电话
  • 网站vps被黑湖人最新排名最新排名
  • 如何夸奖客户网站做的好seo课程心得体会
  • 有哪些做电子商务的网站时空seo助手
  • 临沂百度网站电脑培训机构哪个好
  • 无锡专业做网站的公司怎样把自己的产品放到网上销售
  • 大学网站建设管理办法推广技巧
  • 长春做网站公司seo关键词排名优化软件怎么选
  • 网站开发未按合同约定工期完工seo关键词排名怎么提升
  • 创可贴app海报制作网站百度seo优化方法
  • 龙岗品牌网站建设2024年新闻摘抄
  • 南阳住房和城乡建设厅网站招聘网站排名
  • 如何做网站活动封面建站的公司
  • 温州网站建设培训营销推广方案包括哪些内容
  • 厦门 建网站商业软文案例
  • wordpress读者墙站长之家seo工具包
  • 网站建设哪家好灵活苏州久远网络北京搜索引擎关键词优化
  • 网站优化怎么做 有什么技巧东莞seo建站
  • 什么网站可以做游戏机疫情最新数据消息