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

洛杉矶网站建设wordpress如何建导航

洛杉矶网站建设,wordpress如何建导航,唐山哪里建新机场,seo网站培训文章目录 一、索引库1、mapping属性2、索引库的crud 二、文档的crud三、RestClient 一、索引库 es中的索引是指相同类型的文档集合#xff0c;即mysql中表的概念 映射#xff1a;索引中文档字段的约束#xff0c;比如名称、类型 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、floatObject对象 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: linsylinsy.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的版本一致你需要对应到安装在服务器上的版本。 dependencygroupIdorg.elasticsearch.client/groupIdartifactIdelasticsearch-rest-high-level-client/artifactId/dependencypropertiesjava.version8/java.versionelasticsearch.version7.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();ListHotel 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://www.hkea.cn/news/14264433/

相关文章:

  • 工业设计公司属于什么行业百度站长seo
  • 如何做介绍监控公司的网站滨州网站建设腾度
  • 广州机械网站开发网站建设子栏目怎么弄
  • 怎么制作一个自己的网站手机网络不稳定
  • 做网站快速赚钱cms网站建设
  • 河南省建设厅网站154号文件网站后台密码忘记了怎么办 ftp进不去
  • 南宁网站seo推广公司公司起名网
  • 手机网站设计规范做网站找哪个平台好
  • 深圳网站建设及推广服务公司注册微信公众号流程
  • 域名备案完成了怎么建设网站昆明学网站建设
  • 化妆品网站设计论文网页设计作品文章
  • 17网一起做网站专业商城网站建设报价单
  • 浙江省住房和建设厅网站如何进行主题网站的资源建设
  • 服务器租用网站自动划分空间用wordpress安全吗
  • 玄武网站建设网站注册账号有风险吗
  • 做博客网站最好用什么系统购物商场网站开发过程详细说明
  • 多个wordpress站点同步wordpress 注册中文名
  • 网站开发项目需求方案全网自媒体平台
  • 汕头网站建设过程网页版微信怎么艾特别人
  • 新民网站建设价格咨询吉林市建设厅网站
  • 公司网站推广执行方案域名解析查询网
  • 设计图片素材网站有哪些wordpress全功能主题
  • 合肥网站建设王正刚wordpress腾讯课堂
  • 深圳市网站建设科技凡科建站提示网站建设中
  • 公司怎么做网站平台东莞建设网站开发
  • 淘宝电子网站建设论文谷歌网站流量分析
  • 深圳网站优化计划抖音代运营策划方案
  • 做出网站佛山网站外包
  • 凡科网站怎么做建站商城建设公司
  • 广东建设工程注册中心网站房子装修价格