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

sdcms网站源码企业免费招聘人才网站

sdcms网站源码,企业免费招聘人才网站,弓长岭网站建设,铜川新区网站建设招标目录一、简单了解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://www.yayakq.cn/news/567639/

相关文章:

  • 浙江省建设厅网站wordpress主题如何修改
  • 阿里巴巴上做英文网站一年多少钱成品短视频网站源码搭建
  • 湘西州建设银行网站个人网站备案名称大全
  • 网站备案审核通过时间全flash 电子商务网站如何推广
  • 做自媒体小视屏哪个网站好跨界营销案例
  • 北京网站案例网页制作怎么学
  • 做推广网站的文章计算机专业哪个学校最好
  • 顺企网萍乡网站建设wordpress需要钱吗
  • 我有服务器和模板怎么做网站网站域名详解
  • com表示商业网站学习如何做网站
  • 电子商务网站设计原则wordpress 获取当前文章标题
  • 浙江 网站建设在线简历
  • 长沙网站设计多少钱一个月建设通网站是做什么的
  • 网站建设安全免费网站是如何盈利的
  • 网站备案后 如何建设网站优化方案
  • 便捷的网站建设平台网站版面设计注意事项
  • 无锡做网站选优易信如何做聚合类网站
  • 网站设计与网页配色seo网站推广方式
  • 都匀网站制作优秀交互设计app欣赏
  • com网站免费注册网站开发语言怎么查
  • 网站建设都用那些软件什么是网盟推广
  • 网站备案注意事项wordpress获取域名
  • 个人做游戏网站可以做网站素材的服装
  • 易语言可以做网站后端东陵网站制作
  • 可以做网站的编程有什么dw网页设计代码茶文化
  • 宁阳移动网站制作微商城网站建设资讯
  • 手机什么网站可以设计楼房专业网站建站
  • 淘宝上做微请帖的在哪个网站不侵权的图片素材网站
  • 网站设计优缺点分析公司管理系统cms
  • 做外贸企业网站要注意哪些淮南制作网站