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

网站开发程序是什么发布新闻稿

网站开发程序是什么,发布新闻稿,门户网站运营是什么,自己模板做网站首先在官网下载elasticsearch8.9版本&#xff0c;以及8.9版本的kibana。 解压&#xff0c;点击es8.9bin目录下的elasticsearch.bat文件启动es 如图所示即为成功。 启动之后打开idea&#xff0c;添加依赖 <dependency><groupId>com.fasterxml.jackson.core</g…

首先在官网下载elasticsearch8.9版本,以及8.9版本的kibana。

解压,点击es8.9bin目录下的elasticsearch.bat文件启动es

如图所示即为成功。 

 启动之后打开idea,添加依赖

        <dependency><groupId>com.fasterxml.jackson.core</groupId><artifactId>jackson-databind</artifactId><version>2.13.2</version></dependency><dependency><groupId>org.glassfish</groupId><artifactId>jakarta.json</artifactId><version>2.0.1</version></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-configuration-processor</artifactId><optional>true</optional></dependency><dependency><groupId>co.elastic.clients</groupId><artifactId>elasticsearch-java</artifactId><version>8.9.0</version></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><scope>test</scope></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId><version>2.7.10</version></dependency>

之后配置配置文件

@Configuration
public class ElasticSearchConfig {@Beanpublic ElasticsearchClient elasticsearchClient(){RestClient client = RestClient.builder(new HttpHost("localhost", 9200,"http")).build();ElasticsearchTransport transport = new RestClientTransport(client,new JacksonJsonpMapper());return new ElasticsearchClient(transport);}
}

这时候就已经可以使用了基本使用操作如下代码块


@SpringBootTest
class SpringDataJpaApplicationTests {@Autowiredprivate ElasticsearchClient client;/*创建索引*/@Testvoid test01() throws Exception {//写法比RestHighLevelClient更加简洁CreateIndexResponse indexResponse = client.indices().create(c -> c.index("user"));}//查询数据@Testpublic void queryTest() throws IOException {GetIndexResponse getIndexResponse = client.indices().get(i -> i.index("user"));System.out.println(getIndexResponse);}//判断索引是否存在@Testpublic void existsTest() throws IOException {BooleanResponse booleanResponse = client.indices().exists(e -> e.index("user"));System.out.println(booleanResponse.value());}//删除索引@Testpublic void deleteTest() throws IOException {DeleteIndexResponse deleteIndexResponse = client.indices().delete(d -> d.index("user"));System.out.println(deleteIndexResponse.acknowledged());}//插入document@Testpublic void addDocumentTest() throws IOException {User user = new User(1, "张三","123123123");IndexResponse indexResponse = client.index(i -> i.index("user")//设置id.id("1")//传入user对象.document(user));}//更新document@Testpublic void updateDocumentTest() throws IOException {UpdateResponse<User> updateResponse = client.update(u -> u.index("user").id("1").doc(new User(1,"user2","123132131")), User.class);}//查询document@Testpublic void queryDocumentTest() throws IOException {GetResponse<User> response = client.get(g -> g.index("user").id("1"), User.class);System.out.println(response);System.out.println(response.source());}//删除document@Testpublic void deleteDocumentTest() throws IOException {DeleteResponse response = client.delete(d -> d.index("user").id("1"));System.out.println(response);}//批量插入document@Testpublic void bulkTest() throws IOException {List<User> users=new CopyOnWriteArrayList<>();users.add(new User(1,"张1","1233"));users.add(new User(2,"张2","1234"));users.add(new User(3,"张3","1235"));users.add(new User(4,"张4","1236"));users.add(new User(5,"张5","1237"));List< BulkOperation> bulkOperationCopyOnWriteArrayList =new CopyOnWriteArrayList<>();//遍历插入bulk中users.stream().forEach(u->{bulkOperationCopyOnWriteArrayList.add(BulkOperation.of(o ->o.index(i->i.document(u))));});System.out.println(bulkOperationCopyOnWriteArrayList);BulkResponse response=client.bulk(b->b.index("user").operations(bulkOperationCopyOnWriteArrayList));System.out.println(response);}//查询
/*	@Testpublic void searchTest() throws IOException {SearchResponse<User> search = client.search(s -> s.index("user")//查询name字段包含hello的document(不使用分词器精确查找).query(q -> q.term(t -> t.field("name").value(v -> v.stringValue("hello"))))//分页查询,从第0页开始查询3个document.from(0).size(3)//按age降序排序.sort(f->f.field(o->o.field("age").order(SortOrder.Desc))),User.class);for (Hit<User> hit : search.hits().hits()) {System.out.println(hit.source());}}*/}

http://www.yayakq.cn/news/882812/

相关文章:

  • 做面膜的网站报班学网站开发价格
  • 数据库电影网站源码seo全网推广营销软件
  • 电子商务网站建设与管理王生春做外汇网站卖判刑多少年
  • 上海大学生做网站的团队美容手机网站模板
  • 河南省住房和城乡建设厅门户网站htm网站
  • 建设银行给税对账在什么网站wordpress 调用备案号
  • 临汾哪里有做网站的网络维护公司经营范围
  • 网站建设哪里接活wordpress360极速模式打不开
  • 做海报有哪些网站周村网站制作价格低
  • 互动网站建设什么意思wordpress 钻石 插件
  • 建筑学院网站重庆网站开发公司
  • 织梦音乐网站网站的排版设计
  • 上传网站安装教程视频教程网站建设公司调研汇报ppt
  • 网站编程入门揭秘杭州亚运会开幕式亮点
  • 怀化网站推广58同城网页版怎么发布信息
  • wordpress阿里云全站加速有好的网站推荐一下吗
  • 电话语音聊天网站建设多少钱什么是 网站的逻辑结构
  • 类似携程网的网站dw建设网站步骤
  • 注册公司网站地址该如何填网站多域名
  • 做网站营业执照经营范围怎么填写网上购物商城毕业设计
  • 给个网站做填空题哪种企业适合做网站
  • 企梦云网站建设西部数码手机网站
  • 如何以目录形式访问网站wordpress+教材主题
  • 园区网互联及网站建设网上推广是什么意思
  • 品牌建设公司网站开发一个软件需要什么技术
  • 免费做网站收录的互动创意网站
  • 无锡地区网站制作公司排名wordpress时间表插件
  • 湘潭做网站找磐石网络一流青岛网站建设软件下载
  • 佛山便宜网站建设自己制作动漫的软件
  • 网站宣传的传统方式有哪些网站交接需要哪些