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

传奇手游最新下载做网站优化的公司

传奇手游最新下载,做网站优化的公司,珠海网站开发排名,整形医院网站建设文章目录 一、索引库1、mapping属性2、索引库的crud 二、文档的crud三、RestClient 一、索引库 es中的索引是指相同类型的文档集合,即mysql中表的概念 映射:索引中文档字段的约束,比如名称、类型 1、mapping属性 mapping映射是对索引库中文…

文章目录

  • 一、索引库
    • 1、mapping属性
    • 2、索引库的crud
  • 二、文档的crud
  • 三、RestClient

一、索引库

es中的索引是指相同类型的文档集合,即mysql中表的概念
映射:索引中文档字段的约束,比如名称、类型

1、mapping属性

mapping映射是对索引库中文档的约束。类似mysql对表单字段的约束

{"id":[1, 2, 3, 4, 5],"name":{"firstname":"明","lastname":"李"}
}
  • type:字段数据类型,常见的类型有:
    • 字符串:text(可分词的文本)、keyword(不可分词的文本,例如国家、品牌、IP地址)
    • 布尔:boolean
    • 日期:date
    • 数值:long、short、byte、integer、double、float
    • Object:对象
      es里面没有数组类型,json格式key、value,允许value有多个值。上图id字段
  • index:是否创建索引,默认为true。就是是否创建倒排索引,不创建之后就不能通过它搜索。
  • analyzer:使用那种分词器
  • properties:该字段的子字段,上面name

2、索引库的crud

# 建立索引库
PUT /linsy
{"mappings": {"properties": {"info": {"type": "text","analyzer": "ik_smart"},"email": {"type": "keyword","index": false},"name": {"type": "object","properties": {"firstname": {"type": "keyword"},"lastName": {"type": "keyword"}}}}}
}

查询索引库 GET /索引库名 GET /linsy
删除索引库 DELETE /索引库名

ES 禁止修改索引库字段类型及属性,会影响整个索引的结构,但是允许在原有索引库中新增字段。
注意不能新增已有字段

PUT /索引库名/_mapping
{"properties": {"新字段名": {"type": "新字段类型"}}
}

二、文档的crud

新增操作

POST /索引库名/_doc/文档id
{"字段1": "值1,"字段2": "值2","字段3": "值3",
}

查询 GET /索引库名/_doc/文档id
删除 DELETE /索引库名/_doc/文档id

# 文档操作
# 插入
POST /linsy/_doc/1
{"age": "11","email": "linsy@linsy.work","info": "this is a first test 文档","name": {"firstname": "明","lastName": "李"}
}GET  /linsy/_doc/1DELETE /linsy/_doc/1POST /linsy/_update/1
{"doc":{"age":1111}
}

修改文档:

  • 全量修改:删除旧文档,添加新文档。就是将上面新增的 DSL 改为 PUT
PUT /索引库名/_doc/文档id
{"字段1": "值1,"字段2": "值2","字段3": "值3",
}
  • 增量修改,修改指定字段
POST /索引库名/_update/文档id
{"doc":{"字段名":"新的值"}
}

三、RestClient

springboot 导入elasticsearch依赖需注意,它默认使用的版本和springboot的版本一致,你需要对应到安装在服务器上的版本。

        <dependency><groupId>org.elasticsearch.client</groupId><artifactId>elasticsearch-rest-high-level-client</artifactId></dependency>
    <properties><java.version>8</java.version><elasticsearch.version>7.17.11</elasticsearch.version></properties>

在这里插入图片描述

在这里插入图片描述
在这里插入图片描述
创建索引库的mapping映射

PUT /hotel
{"mappings": {"properties": {"id":{"type": "keyword"},"name":{"type": "text","analyzer": "ik_max_word","copy_to": "all"},"address":{"type": "keyword","index": false},"price":{"type": "integer"},"score":{"type": "integer"},"brand":{"type": "keyword","copy_to": "all"},"city":{"type": "keyword"},"starName":{"type": "keyword"},"business":{"type": "keyword","copy_to": "all"},"location":{"type": "geo_point"},"pic":{"type": "keyword","index": false},"all":{"type": "text","analyzer": "ik_max_word"}}}
}

RestHighLevelClient 的使用
在这里插入图片描述

        RestHighLevelClient restHighLevelClient = new RestHighLevelClient(RestClient.builder(HttpHost.create("http://http://192.168.52.150:9200")));// index的增删查CreateIndexRequest createIndexRequest = new CreateIndexRequest("linsy");createIndexRequest.source("建立索引库语句(put)", XContentType.JSON);restHighLevelClient.indices().create(createIndexRequest, RequestOptions.DEFAULT);restHighLevelClient.indices().delete(new DeleteIndexRequest("要删除的索引库名"), RequestOptions.DEFAULT);// 判断是否存在boolean b = restHighLevelClient.indices().exists(new GetIndexRequest("索引库名"), RequestOptions.DEFAULT);

es8.x已经弃用了RestHighLevelClient
官方创建RestClient文档

文档的crud
在这里插入图片描述
查询文档
在这里插入图片描述

在这里插入图片描述

    @Autowiredprivate IHotelService iHotelService;@BeforeEachpublic void before() {restHighLevelClient = new RestHighLevelClient(RestClient.builder(HttpHost.create("http://192.168.52.150:9200")));}@AfterEachpublic void after() throws IOException {restHighLevelClient.close();}@Testpublic void addDocumentTest() throws IOException {Hotel hotel = iHotelService.getById(61075);HotelDoc hotelDoc = new HotelDoc(hotel);IndexRequest indexRequest = new IndexRequest("hotel").id(hotel.getId().toString());indexRequest.source(JSON.toJSONString(hotelDoc), XContentType.JSON);restHighLevelClient.index(indexRequest, RequestOptions.DEFAULT);}@Testpublic void queryDocumentTest() throws IOException {GetResponse getResponse = restHighLevelClient.get(new GetRequest("hotel", "61075"), RequestOptions.DEFAULT);String json = getResponse.getSourceAsString();System.out.println(json);}@Testpublic void updateDocumentTest() throws IOException {UpdateRequest updateRequest = new UpdateRequest("hotel", "61075");updateRequest.doc("city", "北京","score", "90");restHighLevelClient.update(updateRequest, RequestOptions.DEFAULT);}@Testpublic void deleteDocumentTest() throws IOException {restHighLevelClient.delete(new DeleteRequest("hotel", "61075"), RequestOptions.DEFAULT);}@Testpublic void batchAdd() throws IOException {BulkRequest bulkRequest = new BulkRequest();List<Hotel> list = iHotelService.list();for (Hotel hotel : list) {HotelDoc hotelDoc = new HotelDoc(hotel);bulkRequest.add(new IndexRequest("hotel").id(hotel.getId().toString()).source(JSON.toJSONString(hotelDoc), XContentType.JSON));}restHighLevelClient.bulk(bulkRequest, RequestOptions.DEFAULT);}

文章转载自:
http://retsina.gtqx.cn
http://pga.gtqx.cn
http://banco.gtqx.cn
http://carpale.gtqx.cn
http://fortuneteller.gtqx.cn
http://antirabic.gtqx.cn
http://smithite.gtqx.cn
http://reheating.gtqx.cn
http://plastered.gtqx.cn
http://undiscoverable.gtqx.cn
http://saddlefast.gtqx.cn
http://cythera.gtqx.cn
http://ceric.gtqx.cn
http://aventall.gtqx.cn
http://pard.gtqx.cn
http://rangey.gtqx.cn
http://tunnel.gtqx.cn
http://hyperbola.gtqx.cn
http://rectorship.gtqx.cn
http://needlecraft.gtqx.cn
http://contradistinguish.gtqx.cn
http://hypanthial.gtqx.cn
http://sandman.gtqx.cn
http://veni.gtqx.cn
http://electropaint.gtqx.cn
http://pretest.gtqx.cn
http://smudgy.gtqx.cn
http://isopycnosis.gtqx.cn
http://entomic.gtqx.cn
http://boughpot.gtqx.cn
http://mycoflora.gtqx.cn
http://coxcomb.gtqx.cn
http://prussianize.gtqx.cn
http://stuntwoman.gtqx.cn
http://trousers.gtqx.cn
http://demonolatry.gtqx.cn
http://standoff.gtqx.cn
http://cronk.gtqx.cn
http://beloved.gtqx.cn
http://caecotomy.gtqx.cn
http://haitian.gtqx.cn
http://filicauline.gtqx.cn
http://ermined.gtqx.cn
http://ciao.gtqx.cn
http://cannelure.gtqx.cn
http://eec.gtqx.cn
http://marlpit.gtqx.cn
http://conveyancer.gtqx.cn
http://stripling.gtqx.cn
http://stifling.gtqx.cn
http://njord.gtqx.cn
http://hectovolt.gtqx.cn
http://caesura.gtqx.cn
http://prefecture.gtqx.cn
http://frost.gtqx.cn
http://checker.gtqx.cn
http://panmixia.gtqx.cn
http://forthy.gtqx.cn
http://crateriform.gtqx.cn
http://arhythmic.gtqx.cn
http://transmission.gtqx.cn
http://bhil.gtqx.cn
http://tittlebat.gtqx.cn
http://knell.gtqx.cn
http://wang.gtqx.cn
http://talcose.gtqx.cn
http://sodar.gtqx.cn
http://blackhearted.gtqx.cn
http://gastrula.gtqx.cn
http://clearance.gtqx.cn
http://large.gtqx.cn
http://afeared.gtqx.cn
http://angiography.gtqx.cn
http://flare.gtqx.cn
http://lippie.gtqx.cn
http://interflow.gtqx.cn
http://agrimony.gtqx.cn
http://sheargrass.gtqx.cn
http://pascual.gtqx.cn
http://cubby.gtqx.cn
http://compotator.gtqx.cn
http://porterage.gtqx.cn
http://tantrum.gtqx.cn
http://shikar.gtqx.cn
http://extraction.gtqx.cn
http://isochar.gtqx.cn
http://responsa.gtqx.cn
http://advertisement.gtqx.cn
http://isoteniscope.gtqx.cn
http://precocious.gtqx.cn
http://unblamable.gtqx.cn
http://isobaric.gtqx.cn
http://benumb.gtqx.cn
http://yoick.gtqx.cn
http://oilskin.gtqx.cn
http://acidogenic.gtqx.cn
http://admass.gtqx.cn
http://infrahuman.gtqx.cn
http://slinkskin.gtqx.cn
http://lepidosis.gtqx.cn
http://www.15wanjia.com/news/87690.html

相关文章:

  • 网络营销话题讨论哈尔滨网络优化推广公司
  • 商城网站类建设哪家好关键词优化需要从哪些方面开展
  • 单页网站的区别江苏网站推广
  • 萧山做网站网络服务主要包括
  • 住房与城乡建设部违法举报网站网络推广费用计入什么科目
  • 网站开发 实时更新百度q3财报减亏170亿
  • 和幼儿做网站百度资源
  • 泸州网站制作兰州seo网站建设
  • 支持企业网站发布要怎么做餐饮营销策划与运营
  • 找个做游戏的视频网站好网站优化排名优化
  • 重庆网站开发商城网店培训班
  • 福田网站建设seo信科网络推广的主要工作内容
  • 漂亮网站底部代码怎么优化关键词排名优化
  • 句容工程建设招标网站最新国际军事动态
  • 温岭网站制作百度站长链接提交
  • 网站制作软件叫什么微商软文推广平台
  • 网站图片切换怎么做的99个创意营销方案
  • 制作应用的网站上海网站建设开发公司
  • 沈阳网站推广¥做下拉去118cr制作自己的网站
  • 建行个人网上银行上海网络优化服务
  • 做食物外网视频网站北京全网营销推广
  • 阿里云做的网站这么卡的学it什么培训机构好
  • 做网站的公司在哪网络营销推广的
  • 专业制作证件网站免费制作链接
  • 浏览器网址导航单页站好做seo吗
  • 网站修改dns优书网首页
  • 手机设计logo软件seo 优化公司
  • 做网站那些好重庆seo俱乐部
  • 网上共青团建设登录网站小程序seo推广技巧
  • 邯郸做wap网站找谁广东公共广告20120708