Es

elasticsearch学习笔记(一)-elasticsear

2021-06-26  本文已影响0人  Shawn_Shawn

ElasticSearch

elasticsearch简介

elasticsearch的应用场景

elasticsearch家族

elasticsearch的生态圈

logstash

简介
特性

kibana

简介
elk-stack.png

Beats层主要负责收集数据,可以直接存储到elastic search,也可以交给logstash进行解析过滤等处理操作,再存储到elastic search,elasticsearch就是存储引擎,提供api用于搜索数据,分析数据等操作,kibana与elasticsearch进行可视化交互。

elasticsearch的基本概念

Document

Document MetaData
 "_index" : "movies",
 "_type" : "_doc",
 "_id" : "37475",
 "_score" : 1.0,
 "_source" : {
 "genre" : [
 "Drama"
 ],
 "id" : "37475",
 "year" : 2005,
 "title" : "Unfinished Life, An",
 "@version" : "1"
 }
}

document metaData主要用于标注文档的相关信息

Index

// index settings
{
 "settings":
 {
 "index":
 {
 "creation_date": "1624690171977",
 "number_of_shards": "1",
 "number_of_replicas": "1",
 "uuid": "HqFyAwvOQ8Ctfwy7Cbwz-A",
 "version":
 {
 "created": "7090299"
 },
 "provided_name": "movies"
 }
 }
}


// index mapping
{
 "mappings": {
 "_doc": {
 "properties": {
 "@version": {
 "type": "text",
 "fields": {
 "keyword": {
 "type": "keyword",
 "ignore_above": 256
 }
 }
 },
 "genre": {
 "type": "text",
 "fields": {
 "keyword": {
 "type": "keyword",
 "ignore_above": 256
 }
 }
 },
 "id": {
 "type": "text",
 "fields": {
 "keyword": {
 "type": "keyword",
 "ignore_above": 256
 }
 }
 },
 "title": {
 "type": "text",
 "fields": {
 "keyword": {
 "type": "keyword",
 "ignore_above": 256
 }
 }
 },
 "year": {
 "type": "long"
 }
 }
 }
 }
}

Type

在一个索引中,你可以定义一种或多种类型。一个类型是你的索引的一个逻辑上的分类/分区,其语义完全由你来定。通常,会为具有一组相同字段的文档定义一个类型。比如说,我们假设你运营一个博客平台 并且将你所有的数据存储到一个索引中。在这个索引中,你可以为用户数据定义一个类型,为博客数据定义另一个类型,当然,也可以为评论数据定义另一个类型。

需要注意的是:

  1. 在7.0之前,一个index可以设置多个types

  2. 6.0开始,Type已经被Deprecated。7.0开始,一个索引只能创建一个Type - _doc

  3. 8.0将会被彻底被废弃

Cluster

# 查看集群状态
curl -i http://192.168.0.41:9200/_cluster/health
 "cluster_name": "es_demo",
 "status": "yellow",
 "timed_out": false,
 "number_of_nodes": 1,
 "number_of_data_nodes": 1,
 "active_primary_shards": 7,
 "active_shards": 7,
 "relocating_shards": 0,
 "initializing_shards": 0,
 "unassigned_shards": 1,
 "delayed_unassigned_shards": 0,
 "number_of_pending_tasks": 0,
 "number_of_in_flight_fetch": 0,
 "task_max_waiting_in_queue_millis": 0,
 "active_shards_percent_as_number": 87.5
}

Node

节点类型 配置参数 默认值
master-eligible node node.master true
data node node.data true
ingest node.ingest true
coordinating only 每个节点默认都是coordinating node。设置其他类型全部为false。
machine learning node.ml true(enable x-pack)
Master Node & Master-eligible Nodes
Data Node & Coordinating Node
Hot & Warm Node
Machine Learning Node
Tribe Node

Shard & Replica

elasticsearch vs rdbms

RDBMS ElasticSearch
Table Index
Row Document
Column Field
Schema Mapping
SQL DSL

elasticsearch高性能的全文检索,不支持事务,不支持JOIN

上一篇 下一篇

猜你喜欢

热点阅读