Elasticsearch

站内搜索,分布式全网搜索引擎

官网:https://www.elastic.co/cn

1、安装ES服务

下载默认是最新版,这里下载的是7.6.1版

下载后解压至指定文件夹:进入到bin目录双击打开elasticsearch.bat

访问:http://127.0.0.1:9200/

ES安装成功

2、安装数据可视化界面

数据可视化界面 elasticsearch head:
前提是安装nodejs
使用时会出现 **跨域问题,**解决方法:在上面那安装ES的文件下找到config,进入config找到elasticsearch.yml文件,在这里配置:

复制代码
# 开启跨域
http.cors.enabled: true
# 所有人访问
http.cors.allow-origin: "*"

保存后退出。

启动成功

访问:http://localhost:9100

3、安装可视化 kibana 组件

Kibana 是一个针对 Elasticsearch 的开源分析及可视化平台,用来搜索、查看交互
存储在 Elasticsearch 索引中的数据。
使用 Kibana,可以通过各种图表进行高级数据分析及展示。Kibana 让海量数据更
容易理解。
下载版本要和 ES 版本一致
下载解压


汉化Kibana:找到config下的Kibana.yaml文件

重新启动Kibana
打开网址:http://localhost:5601

4、安装分词器

7.6.1 版下载
https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.6.1/elasticsearch-
analysis-ik-7.6.1.zip
解压
在elasticsearch-7.6.1\plugins目录下创建名称为ik的文件夹,将解压后的文件复
制到 ik 目录.
自定义 ik 分词器(非必要,可以根据实际情况选择配置)
在 elasticsearch-7.6.1\plugins\ik\config
添加 xxx.dic 文件定义词组, .dic 文件必须是 utf-8 编码格式,否则启动报错


在 IKAnalyzer.cfg.xml 文件添加自定义分词器文件

5、IK 分词器

英语分词
标准分词

最少切分

最细粒度划分

6、正向索引和倒排索引

7、索引库基本操作

创建索引库
mapping 属性
mapping 是对索引库中文档的约束,常见的 mapping 属性包括:
type:字段数据类型,常见的简单类型有:
字符串:text(可分词的文本),keyword(精确值,例如:品牌,国家,邮箱)
数值:long、integer、short、byte、double、float、
布尔:boolean
日期:date
对象:object

复制代码
PUT /students
{
  "mappings": {
    "properties": {
      "字段1":{
        "type": "text", 
        "index": true
      },
      "字段2":{
        "type": "text", 
        "index": false
      },
      
    }
  }
}

查询索引库

GET /students

删除索引库

DELETE /students

索引库一旦建立无法修改,可以添加字段

复制代码
PUT /students/_mapping
{
  "properties":{
    "dzcount":{
      "type" : "long",
      "index":false
    }
  }
}

8、ES文档操作

新增文档:POST /索引库名/_doc/文档id

删除文档:DELETE /索引库名/_doc/文档id

修改文档:POST /索引库名/_update/文档id

查询文档:

GET /索引库名/_search

{

"query": {

"match": {

"title": "搜索内容"

}

}

}

9、springboot集成ES

在pom.xml中指定版本必须安装的ES一致

加入依赖:

复制代码
 <!-- ES-->
        <dependency>
            <groupId>org.elasticsearch.client</groupId>
            <artifactId>elasticsearch-rest-high-level-client</artifactId>
        </dependency>
相关推荐
布吉岛没有岛_20 小时前
Hadoop学习_week1
大数据·hadoop
转转技术团队1 天前
分页查询的稳定性陷阱与根治方案
后端·mysql·elasticsearch
阿里云大数据AI技术1 天前
云栖实录 | 洋钱罐基于 EMR Serverless 产品构建全球一体化数字金融平台
大数据·运维
正在走向自律1 天前
大数据时代时序数据库选型指南:从技术架构到实战案例
大数据·架构·时序数据库
攻城狮7号1 天前
万物互联时代,如何选择合适的时序数据库?
大数据·物联网·时序数据库·apache iotdb·sql mcp
黄焖鸡能干四碗1 天前
网络安全态势报告,网络安全风险评估报告文档
大数据·网络·安全·web安全·信息可视化·需求分析
勇往直前plus1 天前
ElasticSearch详解(篇二)
大数据·elasticsearch·jenkins
Hello.Reader1 天前
使用 Flink CDC Elasticsearch Pipeline Connector 打通 MySQL 与 Elasticsearch 的实时链路
mysql·elasticsearch·flink
YongCheng_Liang1 天前
openEuler 22.03 LTS 部署 ELK(Elasticsearch+Logstash+Kibana)完整教程
linux·运维·elk·elasticsearch
Elasticsearch1 天前
Elasticsearch:如何在 ES|QL 中使用 FORK 及 FUSE 命令来实现混合搜索 - 9.1+
elasticsearch