当前位置: 首页 > 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.dt0577.cn/news/18830.html

相关文章:

  • 政府门户网站建设 苏州电脑系统优化软件十大排名
  • 大连企业做网站如何建一个自己的网站
  • 上海网站制作设计公司网上商城建设
  • 网站网格设计seo搜索引擎优化就业指导
  • 成都网页开发潍坊网站seo
  • 做网站如何赢利的电子商务与网络营销教案
  • 毕业设计做系统好还是网站好深圳关键词优化怎么样
  • 网站建设哪里有培训机构seo
  • 北京市建设信息网站sem是什么显微镜
  • 软件学校网站模板教你免费申请个人网站
  • 网站做短视频业务许可怎样做自己的网站
  • 广州专业的网站建设国外域名购买
  • 网站开发专业术语没经验可以做电商运营吗
  • 网站开发数据库连接失败关键词完整版免费听
  • 国内优秀网站设计欣赏seo兼职论坛
  • asp在网站制作中的作用郑州百度推广哪家好
  • 百度在哪些城市有分公司厦门百度seo点击软件
  • 新闻稿件广东seo网站推广
  • 深圳华强做网站查找网站
  • 可信网站认证办理google下载
  • 邯郸做移动网站的公司北京百度推广客服电话多少
  • 深圳品牌网站建设公司哪家好2022年小学生新闻摘抄十条
  • 学做烘焙的网站搜索引擎推广与优化
  • 石河子做网站的公司如何在百度上做广告宣传
  • 论坛网站建设需要多少钱网店运营培训
  • 萧山做网站的公司新网站快速收录
  • 广东网站营销seo方案网络营销策划书总结
  • 接网站建设的平台合肥网站优化公司
  • 家教响应式网站沈阳seo代理计费
  • 广告设计公司开店策划seo搜索引擎优化方法