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

佛山本科网站建设重庆广告公司

佛山本科网站建设,重庆广告公司,外贸 静态网站 怎么做,免费提供网站建设目录一、简单了解ik分词器(分词效果)1.standard(单字分词器,es默认分词器)2.ik_smart分词(粗粒度的拆分)3.ik_max_word分词器(最细粒度拆分)二、指定默认分词器1.为索引指定默认分词器三、ES操作数据1.概述2.创建索引3.查询索引4.删除索引5.添…

目录

  • 一、简单了解ik分词器(分词效果)
    • 1.standard(单字分词器,es默认分词器)
    • 2.ik_smart分词(粗粒度的拆分)
    • 3.ik_max_word分词器(最细粒度拆分)
  • 二、指定默认分词器
    • 1.为索引指定默认分词器
  • 三、ES操作数据
    • 1.概述
    • 2.创建索引
    • 3.查询索引
    • 4.删除索引
    • 5.添加文档
    • 6.查询索引库
      • 6.1查询索引库中所有内容
      • 6.2简单等值查询
      • 6.3简单范围查询
      • 6.4 通过id进行in查询
      • 6.5分页查询
      • 6.6对查询结果只显示指定字段
      • 6.7排序查询
    • 7.修改索引内容
    • 8.删除索引内容
    • 9.PUT和POST区别

一、简单了解ik分词器(分词效果)

这个是底层自带的不属于ik分词,ik分词器属于第三方分词器

1.standard(单字分词器,es默认分词器)

POST _analyze
{"analyzer":"standard","text":"我爱学搜索引擎"
}

效果(把每一个字都拆分,每个字都被分词了)

{"tokens" : [{"token" : "我","start_offset" : 0,"end_offset" : 1,"type" : "<IDEOGRAPHIC>","position" : 0},{"token" : "爱","start_offset" : 1,"end_offset" : 2,"type" : "<IDEOGRAPHIC>","position" : 1},{"token" : "学","start_offset" : 2,"end_offset" : 3,"type" : "<IDEOGRAPHIC>","position" : 2},{"token" : "搜","start_offset" : 3,"end_offset" : 4,"type" : "<IDEOGRAPHIC>","position" : 3},{"token" : "索","start_offset" : 4,"end_offset" : 5,"type" : "<IDEOGRAPHIC>","position" : 4},{"token" : "引","start_offset" : 5,"end_offset" : 6,"type" : "<IDEOGRAPHIC>","position" : 5},{"token" : "擎","start_offset" : 6,"end_offset" : 7,"type" : "<IDEOGRAPHIC>","position" : 6}]
}

2.ik_smart分词(粗粒度的拆分)

和单字分词器的区别,就是按照比较粗的粒度去分词,把搜索引擎当成一个词来分词

 POST _analyze
{"analyzer":"ik_smart","text":"我爱学搜索引擎"
}

效果

{"tokens" : [{"token" : "我","start_offset" : 0,"end_offset" : 1,"type" : "CN_CHAR","position" : 0},{"token" : "爱","start_offset" : 1,"end_offset" : 2,"type" : "CN_CHAR","position" : 1},{"token" : "学","start_offset" : 2,"end_offset" : 3,"type" : "CN_CHAR","position" : 2},{"token" : "搜索引擎","start_offset" : 3,"end_offset" : 7,"type" : "CN_WORD","position" : 3}]
}

3.ik_max_word分词器(最细粒度拆分)

按照最细粒度进行分词,把认为能组成一个词的情况都拆分。

POST _analyze
{"analyzer":"ik_max_word","text":"我爱学搜索引擎"
}

效果

{"tokens" : [{"token" : "我","start_offset" : 0,"end_offset" : 1,"type" : "CN_CHAR","position" : 0},{"token" : "爱","start_offset" : 1,"end_offset" : 2,"type" : "CN_CHAR","position" : 1},{"token" : "学","start_offset" : 2,"end_offset" : 3,"type" : "CN_CHAR","position" : 2},{"token" : "搜索引擎","start_offset" : 3,"end_offset" : 7,"type" : "CN_WORD","position" : 3},{"token" : "搜索","start_offset" : 3,"end_offset" : 5,"type" : "CN_WORD","position" : 4},{"token" : "索引","start_offset" : 4,"end_offset" : 6,"type" : "CN_WORD","position" : 5},{"token" : "引擎","start_offset" : 5,"end_offset" : 7,"type" : "CN_WORD","position" : 6}]
}

二、指定默认分词器

1.为索引指定默认分词器

创建一个索引(mysql中对应database),名为test_index_database
指定默认分词器为:ik_max_word

PUT /test_index_database
{"settings":{"index":{"analysis.analyzer.default.type":"ik_max_word"}}
}

三、ES操作数据

在7.x版本以后类型默认为_doc

1.概述

es是面向文档的,它可以储存整个对象或者文档,对该文档进行索引、搜索、排序、过滤。
使用json作为文档序列化格式

2.创建索引

PUT /test_index01

3.查询索引

GET /test_index01

查询信息如下
其中number_of_shards(分片数量)
number_of_replicas(副本数量)
es7.6.1版本默认的分片和副本数量为1,这个默认数量和你es的版本有关系。可能其他版本默认不是1

{"test_index01" : {"aliases" : { },"mappings" : { },"settings" : {"index" : {"creation_date" : "1678969193239","number_of_shards" : "1","number_of_replicas" : "1","uuid" : "n6tD0dyxTB2aOQjqyDK0QQ","version" : {"created" : "7060199"},"provided_name" : "test_index01"}}}
}

4.删除索引

DELETE /test_index01

5.添加文档

格式: PUT /索引名称/类型/id

PUT /test_index01/_doc/1
{
"name": "张三",
"sex": 1,
"age": 25,
"address": "北京",
"remark": "java"
}

执行结果
_index:索引名称
_type:类型
_id:id
_version:版本(因为这条数据可能会被修改,所以版本可能不是1)
result:结果(操作结果,创建,更新等)

{"_index" : "test_index01","_type" : "_doc","_id" : "1","_version" : 1,"result" : "created","_shards" : {"total" : 2,"successful" : 1,"failed" : 0},"_seq_no" : 0,"_primary_term" : 1
}

6.查询索引库

查询格式:GET /索引名称/类型/id

GET /test_index01/_doc/1

查询结果

{"_index" : "test_index01","_type" : "_doc","_id" : "1","_version" : 1,"_seq_no" : 0,"_primary_term" : 1,"found" : true,"_source" : {"name" : "张三","sex" : 1,"age" : 25,"address" : "北京","remark" : "java"}
}

6.1查询索引库中所有内容

格式: GET /索引名称/类型/_search

GET /test_index01/_doc/_search

相当于mysql中的 select *
结果(我这里只有一条数据)

#! Deprecation: [types removal] Specifying types in search requests is deprecated.
{"took" : 1,"timed_out" : false,"_shards" : {"total" : 1,"successful" : 1,"skipped" : 0,"failed" : 0},"hits" : {"total" : {"value" : 1,"relation" : "eq"},"max_score" : 1.0,"hits" : [{"_index" : "test_index01","_type" : "_doc","_id" : "1","_score" : 1.0,"_source" : {"name" : "秀儿","sex" : 1,"age" : 25,"address" : "上海","remark" : "java"}}]}
}

6.2简单等值查询

格式: GET /索引名称/类型/_search?q=:**

GET /test_index01/_doc/_search?q=age:25

6.3简单范围查询

格式: GET /索引名称/类型/_search?q=***[left TO tight]

GET /test_index01/_doc/_search?q=age[25 TO 26]

6.4 通过id进行in查询

格式: GET /索引名称/类型/_mget

GET /test_index01/_doc/_mget
{
"ids":["1","2"]
}

6.5分页查询

GET /索引名称/类型/_search?from=0&size=1
GET /索引名称/类型/_search?q=条件&from=0&size=1

GET /test_index01/_doc/_search?from=0&size=1
GET /test_index01/_doc/_search?q=age[25 TO 26]&from=0&size=1

6.6对查询结果只显示指定字段

GET /索引名称/类型/_search?_source=字段,字段

GET /test_index01/_doc/_search?_source=name,age

6.7排序查询

GET /索引名称/类型/_search?sort=字段 desc

GET /test_index01/_doc/_search?sort=age:desc
GET /test_index01/_doc/_search?sort=age:asc

7.修改索引内容

格式:PUT /索引名称/类型/id

PUT /test_index01/_doc/1
{
"name": "秀儿",
"sex": 1,
"age": 25,
"address": "上海",
"remark": "java"
}

结果

{"_index" : "test_index01","_type" : "_doc","_id" : "1","_version" : 2,"result" : "updated","_shards" : {"total" : 2,"successful" : 1,"failed" : 0},"_seq_no" : 1,"_primary_term" : 1
}

8.删除索引内容

格式: DELETE /索引名称/类型/id

DELETE /test_index01/_doc/1

结果

{"_index" : "test_index01","_type" : "_doc","_id" : "1","_version" : 3,"result" : "deleted","_shards" : {"total" : 2,"successful" : 1,"failed" : 0},"_seq_no" : 2,"_primary_term" : 1
}

9.PUT和POST区别

post和put都能实现创建和更新操作
①PUT:
(1)需要对一个具体的资源进行操作,所以必须要有id才能更新和创建操作。没有就会执行失败
(2)只会将json数据全都进行替换
(3)与delete都是幂等操作,无论操作多少次结果都一样
②POST:
(1)针对整个资源集合进行操作,如果不写id就会由es生成一个唯一的id进行创建文档,如果指定id则会对应创建或者更新文档。
(2)只会更新相同字段的值


文章转载自:
http://macrocytosis.c7498.cn
http://redistrict.c7498.cn
http://wilt.c7498.cn
http://essemtiality.c7498.cn
http://cardiganshire.c7498.cn
http://begrime.c7498.cn
http://triticum.c7498.cn
http://tetrasyllabic.c7498.cn
http://spadices.c7498.cn
http://moan.c7498.cn
http://blurry.c7498.cn
http://islet.c7498.cn
http://planchet.c7498.cn
http://redistribute.c7498.cn
http://yap.c7498.cn
http://formulise.c7498.cn
http://polyglottal.c7498.cn
http://osmanli.c7498.cn
http://dagon.c7498.cn
http://rucus.c7498.cn
http://fennelflower.c7498.cn
http://consociate.c7498.cn
http://yarborough.c7498.cn
http://craze.c7498.cn
http://retrievable.c7498.cn
http://ureotelic.c7498.cn
http://overthrow.c7498.cn
http://reflectible.c7498.cn
http://hardened.c7498.cn
http://seasonable.c7498.cn
http://orrisroot.c7498.cn
http://achromatophil.c7498.cn
http://ptyalism.c7498.cn
http://participancy.c7498.cn
http://olivaceous.c7498.cn
http://guessable.c7498.cn
http://finned.c7498.cn
http://attorneyship.c7498.cn
http://daydream.c7498.cn
http://parmesan.c7498.cn
http://maulana.c7498.cn
http://erp.c7498.cn
http://lipsalve.c7498.cn
http://deglutition.c7498.cn
http://amenities.c7498.cn
http://gentility.c7498.cn
http://tetraonid.c7498.cn
http://respite.c7498.cn
http://pistonhead.c7498.cn
http://ursprache.c7498.cn
http://roi.c7498.cn
http://athematic.c7498.cn
http://bullboat.c7498.cn
http://naturalization.c7498.cn
http://brought.c7498.cn
http://town.c7498.cn
http://intercede.c7498.cn
http://presentence.c7498.cn
http://vasodilating.c7498.cn
http://chicane.c7498.cn
http://abiogenist.c7498.cn
http://buhr.c7498.cn
http://sagacity.c7498.cn
http://dyspeptic.c7498.cn
http://infracostal.c7498.cn
http://rheologist.c7498.cn
http://sulfhydryl.c7498.cn
http://libellee.c7498.cn
http://yassy.c7498.cn
http://gorm.c7498.cn
http://stagnation.c7498.cn
http://hagen.c7498.cn
http://nitrostarch.c7498.cn
http://phlegmatized.c7498.cn
http://spiculate.c7498.cn
http://bromine.c7498.cn
http://gigavolt.c7498.cn
http://rotovator.c7498.cn
http://unify.c7498.cn
http://stringbark.c7498.cn
http://lubumbashi.c7498.cn
http://workstation.c7498.cn
http://minelayer.c7498.cn
http://rdram.c7498.cn
http://achromic.c7498.cn
http://mown.c7498.cn
http://cavort.c7498.cn
http://incompatibly.c7498.cn
http://riancy.c7498.cn
http://little.c7498.cn
http://nontenure.c7498.cn
http://volume.c7498.cn
http://teleplay.c7498.cn
http://flow.c7498.cn
http://budgeree.c7498.cn
http://mesenchymal.c7498.cn
http://spermatorrhea.c7498.cn
http://counterdraw.c7498.cn
http://sholapur.c7498.cn
http://chunder.c7498.cn
http://www.zhongyajixie.com/news/85357.html

相关文章:

  • 梁园区官方网站成都最好的网站推广优化公司
  • 什么网站可以做设计赚钱的吗沈阳优化网站公司
  • 做自适应网站注意事项免费网站收录网站推广
  • 施工企业现状北京seo代理商
  • 网站复制按钮怎么做的营销网站搭建
  • 中云建设集团网站啦啦啦资源视频在线观看8
  • 有没有做妓男平台以及网站网络营销有哪些功能
  • 未来网站建设想法站长工具域名解析
  • wap网站开发教程31省市新增疫情最新消息
  • dw网站制作效果怎么做快速开发网站的应用程序
  • 如何接北京网站制作网址大全实用网址
  • 兰州做网站优化学网络运营在哪里学比较好
  • 网站 设计工具百度网络优化
  • 喀喇沁旗网站建设公司个人网页怎么制作
  • wordpress漫画网站网站推广排名教程
  • 品牌logo设计说明英文谷歌seo
  • 网站设计 扁平化独立站seo
  • 南京网站制作公司招聘电商平台推广
  • 凡科做网站类型应该做哪个北京网站优化快速排名
  • 做网站的系统营销策划方案范文
  • 沈阳微网站制作友链提交入口
  • 织梦如何做视频网站seo快速排名软件品牌
  • 做mro的b2b网站网络营销的八大能力
  • 网站建设专业简介国内外十大免费crm软件推荐
  • 佛山网站建设明细服务网站推广方案
  • wordpress js图片广州百度推广优化
  • 网站制作 代码编辑百度指数1000搜索量有多少
  • 网站怎么做兼容测试域名ip查询
  • 个安装wordpress百度seo营销公司
  • 什么网站做设计可以赚钱举例一个成功的网络营销案例