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

乐山网站制作公司seo网站制作优化

乐山网站制作公司,seo网站制作优化,宁波seo推广方式排名,重庆外贸网站建设公司排名文章目录 1、Elastic Search介绍1.1、ES 的数据结构1.2、ES 为什么查询快1.3、CRUD 2、Spring Boot 整合 ES 1、Elastic Search介绍 ‌Elasticsearch‌是一个分布式的、基于RESTful API的搜索和分析引擎,广泛用于大规模数据存储和快速检索。它最初由Shay Banon于20…

文章目录

  • 1、Elastic Search介绍
    • 1.1、ES 的数据结构
    • 1.2、ES 为什么查询快
    • 1.3、CRUD
  • 2、Spring Boot 整合 ES

1、Elastic Search介绍

‌Elasticsearch‌是一个分布式的、基于RESTful API的搜索和分析引擎,广泛用于大规模数据存储和快速检索。它最初由Shay Banon于2010年开发,是开源的,并且是Elastic Stack(通常称为ELK Stack)的核心组成部分,其他组成部分包括Logstash、Beats(用于数据收集和处理)和Kibana(用于数据可视化)‌
ES 海量数据中快速查找目标数据

EKL ES + Kibana + Logstash

1.1、ES 的数据结构

一个 ES 实例就是一个数据库实例,
索引 index 就是数据表,
字段 Field 就是列信息,
文档 Document 就是行信息。

【对比】
MySQL:select * from test.user where name = “张三”;

ES:GET /test/user/_search?q=name:张三

1、配置 ES,启动 ES 实例

2、新建一个学生索引

3、不需要配置字段,ES 会自动识别

4、一个 JSON 代表一个学生,JSON 字符串中有学生属性字段 Field

MySQL
create table student(name varchar(20),sex char(2),age int
);
ES:
PUT student/_create/1
{"name":"张三","sex":"male","age":18
}

1.2、ES 为什么查询快

因为它采用倒排索引。
举例:

0、我在学校学习,学Java

1、我必须学 Java

2、学校教知识

学校 0、2

学习 0

学 Java 0、1

必须 1

教知识 2

我在学校学习,学Java --》我、在、学校、学习、学 Java

(0,3,100%) 0 章节命中了 3 次,100% 命中率

我必须在学校学Java --》我、必须、在、学校、学 Java

(0,2,66%)

(1,1,33%)

1.3、CRUD

1、添加数据

PUT class/_doc/1
{"name":"张三","age":11
}POST class/_doc
{"name":"王五","age":11
}

2、查询数据

GET class/_doc/1
GET class/_search?q=name:李四
GET class/_search?q=name:(张三 OR 李四)
GET class/_search?q=name:(NOT 张三)
GET class/_search?q=age:<18
GET class/_search?q=age:(>=18 AND <=22)
GET class/_search?q=name:*三
GET class/_search
{"from":0,"size":2
}

3、修改数据

POST class/_update/1
{"doc":{"age":22}
}

4、删除数据

DELETE class/_doc/1

2、Spring Boot 整合 ES

引入依赖

<dependency><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId>
</dependency><dependency><groupId>com.alibaba</groupId><artifactId>fastjson</artifactId><version>1.2.78</version>
</dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-data-elasticsearch</artifactId>
</dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><scope>test</scope>
</dependency>

索引操作

@Autowired
private RestHighLevelClient restHighLevelClient;@Test
void contextLoads() throws Exception {CreateIndexRequest request = new CreateIndexRequest("test_index");CreateIndexResponse response = restHighLevelClient.indices().create(request, RequestOptions.DEFAULT);System.out.println(response.index());
}@Test
void getIndex() throws Exception {GetIndexRequest request = new GetIndexRequest("test_index");boolean exists = restHighLevelClient.indices().exists(request, RequestOptions.DEFAULT);System.out.println(exists);
}@Test
void deleteIndex() throws Exception {DeleteIndexRequest request = new DeleteIndexRequest("test_index");AcknowledgedResponse delete = restHighLevelClient.indices().delete(request, RequestOptions.DEFAULT);System.out.println(delete.isAcknowledged());
}
@Test
void add() throws Exception{User user = new User(1, "张三");IndexRequest request = new IndexRequest("mytest");request.id("2");request.source(JSON.toJSONString(user), XContentType.JSON);IndexResponse response = restHighLevelClient.index(request, RequestOptions.DEFAULT);System.out.println(response.toString());System.out.println(response.status());
}@Test
void get() throws Exception{GetRequest request = new GetRequest("mytest","2");GetResponse response = restHighLevelClient.get(request, RequestOptions.DEFAULT);System.out.println(response.getSourceAsString());System.out.println(response.getSource());
}@Test
void update() throws Exception{UpdateRequest request = new UpdateRequest("mytest","2");User user = new User(2, "李四");request.doc(JSON.toJSONString(user),XContentType.JSON);UpdateResponse response = restHighLevelClient.update(request, RequestOptions.DEFAULT);System.out.println(response.status());
}@Test
void delete() throws Exception{DeleteRequest request = new DeleteRequest("mytest","2");DeleteResponse response = restHighLevelClient.delete(request, RequestOptions.DEFAULT);System.out.println(response.status());
}

EsRepository

package com.southwind.entity;import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;@Data
@Document(indexName = "blog")
public class EsBlog {@Idprivate Integer id;@Field(type = FieldType.Text,analyzer = "ik_max_word")private String title;private String author;@Field(type = FieldType.Text,analyzer = "ik_max_word")private String content;
}
package com.southwind.repository;import com.southwind.entity.EsBlog;
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;public interface EsBlogRepository extends ElasticsearchRepository<EsBlog,Integer> {
}
http://www.ds6.com.cn/news/24537.html

相关文章:

  • 做微信平台图片网站小程序搭建教程
  • 做面包的网站推广网站免费
  • python写网页西安seo优化培训机构
  • 做微网站哪家好深圳做seo有哪些公司
  • 宝安中心做网站多少钱南宁网站优化公司电话
  • 哪家企业的网站做的好电商网站平台有哪些
  • 自建网站的优缺点微商软文范例大全100
  • 合肥网版制作seo对网络推广的作用是什么?
  • 支付网站认证费用怎么做分录2024年阳性最新症状
  • 公共资源交易中心是事业单位吗济南seo整站优化价格
  • 有没有做维修的网站营销云
  • 网站服务器暂时不可用怎么办企业门户网站模板
  • 织梦网站模板教程seo广告优化多少钱
  • 邯郸专业做wap网站seo技术平台
  • 电子商务网站 方案今天国际新闻最新消息
  • c#做asp.net网站推广普通话的文字内容
  • 网站 关键字h5网站制作平台
  • 杭州微网站建设在百度怎么发布作品
  • 遂川网站建设磁力天堂最佳搜索引擎入口
  • 做视频网站如何赚钱steam交易链接可以随便给别人吗
  • 珠海哪里做网站的如何使用网络营销策略
  • 做独立网站的好处网络营销的基本方法有哪些
  • 有什么免费做h5的素材网站怎样在网上做推广
  • 珠海移动网站建设公司怎么制作seo搜索优化
  • 网站如何做中英文效果舆情监测系统排名
  • 广州网站设计制作公司有哪些18款禁用软件黄app免费
  • 静海县建设委员会网站济南seo公司报价
  • 个人网站能 做淘客吗seo厂家电话
  • 西宁做网站君博认同免费网站推广网站在线
  • 免费建小程序网站免费网页设计制作网站