Linking

Capturing Life & Tech

  • 主页
  • 随笔
  • 关于我
所有文章 外链

Linking

Capturing Life & Tech

  • 主页
  • 随笔
  • 关于我

ElasticSearch简单使用

阅读数:次 2018-05-26
字数统计: 688字   |   阅读时长≈ 3分

主要记录四点内容:

  • 1.CRUD
  • 2.searchQuery Language
  • 3.集群
  • 4.数据迁移

文档说明

记录使用到的简单ES知识。

具体查看 Elastic官网

文档内容

1. CRUD

增 CREATE

创建带字段的index

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# es浏览器中-more-create index 请求 POST http://192.168.1.1:9000/create_index/create

# name


# settings
{
"settings": {
"index": {
"creation_date": "1536892448349",
"number_of_shards": "5",
"number_of_replicas": "1",
"uuid": "d56TLML-QxmyAJzBh8D3oA",
"version": {
"created": "5010199"
},
"provided_name": "records"
}
},
"mappings": {
"doc": {
"properties": {
"total": {
"type": "double"
},
"survey_time": {
"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis",
"type": "date"
},
"dev_code": {
"type": "keyword"
},
"name": {
"type": "keyword"
},
"increment": {
"type": "double"
},
"floor": {
"type": "keyword"
},
"run_status": {
"type": "keyword"
},
"building": {
"type": "keyword"
}
}
}
}
}


增加空索引

1
curl -XPUT ‘http://localhost:9200/twitter/'

注:必须先新增空索引,才能插入数据。

增加带数据的索引

1
2
3
4
5
6
7
8

POST /accounts/person/linking
{
"name": "linking",
"sex":"male",
"age": "28",
"provience": "anhui"
}

查 READ

1
GET /accounts/person/linking 

改 UPDATE

1
2
3
4
5
6
POST /accounts/person/linking/_update
{
"doc":{
"age": "29"
}
}

删 DELETE

直接删id

1
DELETE /accounts/person/linking

精确删除,同where

先精确查询一下:

1
2
3
4
5
6
7
POST index/_search

{
"query": {
"term" : { "user" : "Kimchy" }
}
}

https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-term-query.html

再精确删除:

1
2
3
4
5
6
7
POST index/_delete_by_query

{
"query": {
"term" : { "user" : "Kimchy" }
}
}

2. searchQuery Language

支持结构化查询语句,具体请查看API

3. 集群

  • 查看当前集群

http://127.0.0.1:8200/_cat/nodes 查看nodes

http://127.0.0.1:8200/_cat/nodes?v 查看nodes详情

http://127.0.0.1:8200/_cluster/stats 查看集群详细信息

4. 数据迁移

字段类型错误,需要将数据转移出来

闪转腾挪.

基本思路是建立一个与原index 具有相同字段的索引,字段类型可根据需要做调整,然后将数据直接转存过来,之后原index就可以全部删除了。

1
2
3
4
5
6
7
8
9
POST _reindex
{
"source": {
"index": "metricbeat-*"(老的索引名)
},
"dest": {
"index": "metricbeat"(新的索引名)
}
}

参考: ElasticSearch复制索引并修改字段

其他

Kibana

官方介绍如下,其作用可见一斑。

1
Your window into Elastic Search.

ES兄弟,方便进行查询,有自动补全功能,可以自动生成图表等,方便使用。实乃ES可靠的兄弟。

安装也简单,具体请查看官网Kibana

  • 本文作者: Linking
  • 本文链接: https://linking.fun/2018/05/26/ElasticSearch简单使用/
  • 版权声明: 版权所有,转载请注明出处!

扫一扫,分享到微信

微信公众号开发总结
写在读书节后一天
  1. 1. 文档说明
  2. 2. 文档内容
    1. 2.1. 1. CRUD
      1. 2.1.1. 增 CREATE
        1. 2.1.1.1. 创建带字段的index
        2. 2.1.1.2. 增加空索引
        3. 2.1.1.3. 增加带数据的索引
      2. 2.1.2. 查 READ
      3. 2.1.3. 改 UPDATE
      4. 2.1.4. 删 DELETE
        1. 2.1.4.1. 直接删id
        2. 2.1.4.2. 精确删除,同where
    2. 2.2. 2. searchQuery Language
    3. 2.3. 3. 集群
    4. 2.4. 4. 数据迁移
  3. 3. 其他
    1. 3.1. Kibana
© 2015-2026 Linking
GitHub:hexo-theme-yilia-plus by Litten
本站总访问量次 | 本站访客数人
  • 所有文章
  • 外链

tag:

  • weather
  • 需求
  • essay
  • basketball
  • olympic
  • nginx
  • APPScan
  • SQl盲注
  • xss
  • Ajax
  • ajax
  • ai
  • agent
  • openclaw
  • ccf
  • Nginx
  • HTML5
  • html5
  • hmtl5
  • sse
  • JavaScriptCore
  • Oracle
  • operation
  • Linux
  • deploy
  • Mac Office
  • markdown
  • ListView
  • GridView
  • MySQL
  • 慢查询
  • mongodb
  • 转置
  • thought
  • network
  • ubuntu
  • NetworkManager
  • RFKill
  • Netplan
  • avatar
  • cocoa
  • blog
  • Gitalk
  • container
  • macvlan
  • docker
  • oracle
  • cookie
  • patch
  • gitea
  • git
  • iOS
  • https
  • 多线程
  • bundle
  • 兼容性
  • HTTP
  • 绘图
  • cs
  • java
  • 效率
  • 快捷键
  • route
  • nodejs
  • pip
  • arcgis
  • arcgis 建模
  • 标识
  • redis
  • read
  • bookList
  • running
  • showdoc
  • disk
  • unit-test
  • D.Wade
  • thoughts
  • duoduo
  • Python
  • python
  • tomcat
  • 读书节
  • session
  • jdk
  • war
  • 加班
  • Android onclick事件监听
  • 正则
  • 手机品牌匹配
  • ntp
  • OpenLayers
  • Geoserver
  • wechat
  • 微信公众号
  • 爬虫
  • WeChat
  • 张靓颖
  • 动漫
  • vpn
  • PPT
  • MarkDown
  • plan
  • 朱赟
  • 极客时间专栏
  • 极客邦
  • 模块化
  • MVC
  • excel
  • NBA
  • kobe
  • team
  • crawler
  • 进度条
  • ssl
  • book
  • anti-stealing-link
  • Agentic Engineering
  • Vibe Coding
  • Software 3.0
  • Andrej Karpathy
  • LLM
  • Programming

    缺失模块。
    1、请确保node版本大于6.2
    2、在博客根目录(注意不是yilia-plus根目录)执行以下命令:
    npm i hexo-generator-json-content --save

    3、在根目录_config.yml里添加配置:

      jsonContent:
        meta: false
        pages: false
        posts:
          title: true
          date: true
          path: true
          text: false
          raw: false
          content: false
          slug: false
          updated: false
          comments: false
          link: false
          permalink: false
          excerpt: false
          categories: false
          tags: true
    

  • GitHub Trending
  • OpenAI ChatGPT
  • Gitee码云
  • 简书
  • CSDN