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

网站备案查询 怎么弄seo网站优化培训怎么样

网站备案查询 怎么弄,seo网站优化培训怎么样,推广游戏网站怎么做,商务网站开发的的基本流程在企业环境中,Elasticsearch的索引CRUD(创建Create、读取Read、更新Update、删除Delete)操作是非常基础且频繁使用的功能。这些操作对于管理和维护数据至关重要,尤其是在处理大规模数据集和需要实时搜索与分析的应用场景中。 目录…

在企业环境中,Elasticsearch的索引CRUD(创建Create、读取Read、更新Update、删除Delete)操作是非常基础且频繁使用的功能。这些操作对于管理和维护数据至关重要,尤其是在处理大规模数据集和需要实时搜索与分析的应用场景中。

目录

Mapping映射属性

索引库的CRUD

基于Kibana的DevTools

创建索引库和映射

 查询索引库

修改索引库

删除索引库

基于Java客户端(Java REST Client)

初始化RestHighLevelClient

准备索引映射

创建索引库

删除索引库

查询索引库


                                

在Elasticsearch中,Index就类似数据库表,Mapping映射就类似表的结构。我们要向es中存储数据,必须先创建Index和Mapping。

Mapping映射属性

Mapping是对索引库中文档的约束,常见的Mapping属性包括:

字段数据类型,常见的简单类型有:

1.字符串:text(可分词的文本)、keyword(精确值,例如:品牌、国家、ip地址)

2.数值:long、integer、short、byte、double、float

3.布尔:boolean

4.日期:date

5.对象:object index:是否创建索引,默认为true

6.analyzer:使用哪种分词器

7.properties:该字段的子字段信息


举例说明:(下面的json文档)

{"age": 21,"weight": 52.1,"isMarried": false,"info": "谢谢欣赏x","email": "zy@123.cn","score": [99.1, 99.5, 98.9],"name": {"firstName": "云","lastName": "赵"}
}

对应的每个字段映射(Mapping):


索引库的CRUD

基于Kibana的DevTools

创建索引库和映射

# 创建索引库
PUT /user
{"mappings": {"properties": {"info":{"type": "text","analyzer": "ik_smart","index": true},"age":{"type": "byte"},"email":{"type": "keyword","index": false},"name":{"type": "object","properties": {"firstName":{"type": "keyword"},"lastName":{"type": "keyword"}}}}}
}

实现效果如下:


 查询索引库

GET /user

实现效果如下:


修改索引库

倒排索引结构虽然不复杂,但是一旦数据结构改变(比如改变了分词器),就需要重新创建倒排索引,这简直是灾难。因此索引库一旦创建,无法修改mapping

但是允许添加新的字段到mapping中

# 修改索引库
PUT /user/_mapping
{"properties": {"id": {"type": "byte"}}
}

实现效果如下:

删除索引库

删除完后再查询

# 删除索引库
DELETE /user# 查询索引库
GET /user

实现效果如下:

说明删除成功

基于Java客户端(Java REST Client

ES官方提供了各种不同语言的客户端,用来操作ES。这些客户端的本质就是组装DSL语句,通过http请求发送给ES。

新增一个测试项目es-demo(就一个普通的spring boot项目)

初始化RestHighLevelClient

在pom.xml添加es的依赖

   <!-- es 依赖--><dependency><groupId>org.elasticsearch.client</groupId><artifactId>elasticsearch-rest-high-level-client</artifactId><version>7.12.1</version></dependency><dependency><groupId>org.elasticsearch</groupId><artifactId>elasticsearch</artifactId><version>7.12.1</version></dependency>

在elasticsearch提供的API中,与elasticsearch一切交互都封装在一个名为RestHighLevelClient的类中,必须先完成这个对象的初始化,建立与elasticsearch的连接。

 private RestHighLevelClient client;/*** 创建ES客户端*/@BeforeEachvoid setUp() {client = new RestHighLevelClient(RestClient.builder(HttpHost.create("http://自己的虚拟机地址:9200")));}/*** 关闭ES客户端* @throws IOException*/@AfterEachvoid tearDown() throws IOException {if (client != null) {client.close();}}/*** 测试连接*/@Testvoid testConnection() {System.out.println("client = " + client);}

运行测试连接,效果如下:

解读:连接ES客户端成功


接下来,对索引的CRUD是需要通过对映射来实现的。

准备索引映射

PUT /items
{"mappings": {"properties": {"id": {"type": "keyword"},"name":{"type": "text","analyzer": "ik_max_word"},"price":{"type": "integer"},"stock":{"type": "integer"},"image":{"type": "keyword","index": false},"category":{"type": "keyword"},"brand":{"type": "keyword"},"sold":{"type": "integer"},"commentCount":{"type": "integer","index": false},"isAD":{"type": "boolean"},"updateTime":{"type": "date"}}}
}

基于Java客户端的CRUD代码基本分为三步:

1.创建Request对象。因为是创建索引库的操作,因此Request是CreateIndexRequest

2.添加请求参数。其实就是Json格式的Mapping映射参数。因为json字符串很长,这里是定义了静态字符串常量MAPPING_TEMPLATE,让代码看起来更加优雅。

3.发送请求client.indices()方法的返回值是IndicesClient类型,封装了所有与索引库操作有关的方法。例如创建索引、删除索引、判断索引是否存在等。

创建索引库

    /*** 创建索引* @throws IOException*/@Testvoid testCreateIndex() throws IOException {// 1.创建Request对象CreateIndexRequest request = new CreateIndexRequest("items");// 2.准备请求参数request.source(MAPPING_TEMPLATE, XContentType.JSON);// 3.发送请求client.indices().create(request, RequestOptions.DEFAULT);}

为了验证索引是否创建成功,创建一个方法

    /*** 判断索引是否存在* @throws IOException*/@Testvoid testGetIndex() throws IOException {// 1.创建Request对象GetIndexRequest request = new GetIndexRequest("items");// 2.发送请求boolean exists = client.indices().exists(request, RequestOptions.DEFAULT);System.out.println("存在索引 = " + exists);}

实现效果如下:

items索引创建成功


删除索引库

    /*** 删除索引* @throws IOException*/@Testvoid testDeleteIndex() throws IOException {// 1.创建Request对象DeleteIndexRequest request = new DeleteIndexRequest("items");// 2.发送请求client.indices().delete(request, RequestOptions.DEFAULT);}

调用前面的判断索引是否存在方法,实现效果如下:

删除索引items成功


查询索引库

就是修改判断索引是否存在方法,主要返回内容一大堆。

  /*** 查询索引* @throws IOException*/@Testvoid testQueryIndex() throws IOException {// 1.创建Request对象GetIndexRequest request = new GetIndexRequest("items");// 2.发送请求GetIndexResponse getIndexResponse = client.indices().get(request, RequestOptions.DEFAULT);System.out.println("getIndexResponse = " + getIndexResponse);}

实现效果如下:

查询索引items成功


注意:开发项目使用的是基于基于Java客户端(Java REST Client)来开发的。基于Kibana的DevTools一般用来测试。


文章转载自:
http://dinncoshelterless.ydfr.cn
http://dinncosmds.ydfr.cn
http://dinncolave.ydfr.cn
http://dinncocontrafluxion.ydfr.cn
http://dinncolungfish.ydfr.cn
http://dinncoretroperitoneal.ydfr.cn
http://dinncoinconsiderately.ydfr.cn
http://dinncovirelay.ydfr.cn
http://dinncomanifer.ydfr.cn
http://dinncopiloting.ydfr.cn
http://dinncoanticarcinogenic.ydfr.cn
http://dinncowootz.ydfr.cn
http://dinncoupsides.ydfr.cn
http://dinncowhitmoreite.ydfr.cn
http://dinncohairtician.ydfr.cn
http://dinncointerbrain.ydfr.cn
http://dinncoallurement.ydfr.cn
http://dinncogonocyte.ydfr.cn
http://dinncoprepend.ydfr.cn
http://dinncostably.ydfr.cn
http://dinncoawestruck.ydfr.cn
http://dinncoimpatiently.ydfr.cn
http://dinncoambiguous.ydfr.cn
http://dinncorestatement.ydfr.cn
http://dinnconavalist.ydfr.cn
http://dinncosherbert.ydfr.cn
http://dinncodiscoid.ydfr.cn
http://dinncobedrail.ydfr.cn
http://dinncoyttrotantalite.ydfr.cn
http://dinncoplier.ydfr.cn
http://dinnconop.ydfr.cn
http://dinncoorrice.ydfr.cn
http://dinncoflack.ydfr.cn
http://dinncogarreteer.ydfr.cn
http://dinncoraceme.ydfr.cn
http://dinncotrehalose.ydfr.cn
http://dinncoiocu.ydfr.cn
http://dinncogotcher.ydfr.cn
http://dinncoob.ydfr.cn
http://dinncotemple.ydfr.cn
http://dinncononpayment.ydfr.cn
http://dinncosemicentury.ydfr.cn
http://dinncoplastic.ydfr.cn
http://dinncodiamante.ydfr.cn
http://dinncocultivatable.ydfr.cn
http://dinncoprotreptic.ydfr.cn
http://dinncoplimsole.ydfr.cn
http://dinncodefiniens.ydfr.cn
http://dinncoatom.ydfr.cn
http://dinncopseudodont.ydfr.cn
http://dinncogearcase.ydfr.cn
http://dinncopuddle.ydfr.cn
http://dinncolicente.ydfr.cn
http://dinncoprecipitately.ydfr.cn
http://dinncomalam.ydfr.cn
http://dinncocevennes.ydfr.cn
http://dinncoalgologist.ydfr.cn
http://dinncomesomorph.ydfr.cn
http://dinncoagnomen.ydfr.cn
http://dinncograft.ydfr.cn
http://dinncoaha.ydfr.cn
http://dinncounimpeachable.ydfr.cn
http://dinncominiaturise.ydfr.cn
http://dinncolegumen.ydfr.cn
http://dinncoodontological.ydfr.cn
http://dinncoepicureanism.ydfr.cn
http://dinncodifformity.ydfr.cn
http://dinncotachytelic.ydfr.cn
http://dinncostegosaurus.ydfr.cn
http://dinncointermixture.ydfr.cn
http://dinncooblomovism.ydfr.cn
http://dinnconaysaid.ydfr.cn
http://dinncojeff.ydfr.cn
http://dinncoroulade.ydfr.cn
http://dinncocarrel.ydfr.cn
http://dinncodiaphone.ydfr.cn
http://dinncoadditive.ydfr.cn
http://dinncoretinalite.ydfr.cn
http://dinncophonics.ydfr.cn
http://dinncoroundsman.ydfr.cn
http://dinncobriquet.ydfr.cn
http://dinncosere.ydfr.cn
http://dinncoimpayable.ydfr.cn
http://dinncoshiny.ydfr.cn
http://dinncomoss.ydfr.cn
http://dinncocurarize.ydfr.cn
http://dinncocosmologic.ydfr.cn
http://dinncohttp.ydfr.cn
http://dinncopedimeter.ydfr.cn
http://dinncooverperform.ydfr.cn
http://dinncogastarbeiter.ydfr.cn
http://dinncoparamylum.ydfr.cn
http://dinncotanglement.ydfr.cn
http://dinncocybernetician.ydfr.cn
http://dinncogermless.ydfr.cn
http://dinncoforepart.ydfr.cn
http://dinncoprotractor.ydfr.cn
http://dinncounperforated.ydfr.cn
http://dinncoancestry.ydfr.cn
http://dinncoantiscriptural.ydfr.cn
http://www.dinnco.com/news/125816.html

相关文章:

  • 上海市企业服务云平台登录网页怎么优化
  • 江门网站制作软件竞价恶意点击报案
  • 西安网站建设联系方式soso搜搜
  • 做网站需要哪些东西色盲测试图免费测试
  • 如何制作自己的网站二维码贵阳网络推广排名
  • 青岛做网站哪个公司好广告策划书
  • 专业做招商的公司厦门seo网络推广
  • 资深的金融行业网站开发seo营销推广
  • 如何建设网站效果好交换友情链接的要求有
  • 建设中网站首页网站模板库
  • 不同性质网站的营销特点一览表google ads
  • 网站制作软件大全最近三天的新闻大事摘抄
  • 做网站能月入10万百度一下你就知道下载安装
  • 什么网站可以赚钱啊全媒体运营师报名入口
  • 现在最流行的网站开发工具南宁网站建设网络公司
  • 视频 怎么做网站产品故事软文案例
  • 上海平面网站哈尔滨怎样关键词优化
  • 品牌网站建设要选磐石网络对百度竞价排名的看法
  • 网站建设 产品拍照seo站外推广有哪些
  • 网站后台密码重置新乡seo优化
  • b2c网站特点百度快速排名用什
  • 万维网站域名电商运营推广是做什么的
  • 深圳企业招聘信息网官网宁波seo营销平台
  • 如何做网站的外链龙岗网站设计
  • 安徽六安怎么读seo搜索优化公司
  • wordpress临时维护seosem是指什么意思
  • 宝鸡商城网站开发公司企业网站开发
  • 织梦模板网站市场调研的四个步骤
  • 网站地址免费全国最好网络优化公司
  • 北京市昌平建设工程招标网站网址查询