随笔分类 - Elasticsearch
摘要:from elasticsearch import Elasticsearch from elasticsearch.helpers import scan, bulk # 源 ES 连接信息 source_host = 'localhost' source_port = 9200 source_i
阅读全文
摘要:Elasticsearch支持多种查询和更新操作。以下是一些常见的查询和更新操作示例: 查询所有文档: 根据条件查询文档: GET /index_name/_search{ "query": { "match": { "field_name": "search_term" } } } 更新文档: P
阅读全文
摘要:连接 Es: import elasticsearch clinet = elasticsearch.Elasticsearch([{"host": "10.44.99.102", "port": 9200}]) or clinet = Elasticsearch(["10.44.99.102:92
阅读全文
摘要:常用命令 查看集群健康信息 curl -sXGET 127.0.0.1:9200/_cat/health?v curl -sXGET 127.0.0.1:9200/_cluster/health?pretty 1 绿色,最健康的状态,代表所有的分片包括备份都可用 2 黄色,基本的分片可用,但是备份不
阅读全文
摘要:简单方式创建index curl -XPUT ‘http://localhost:9200/twitter/' 在创建索引的时候指定分片和副本数量参数,参数格式采用JSON格式。 curl -XPUT 'http://localhost:9200/twitter/' -d '{ "settings"
阅读全文
摘要:一、创建 mapping 我们可以通过 curl 命令来创建也可以使用 postman 工具等 # 自定义mapping test.org PUT test { "mapping": { "properties": { "id": { "type": "keyword" }, "name": { "
阅读全文
摘要:查看 Elasticsearch 的所有模板 curl -XGET 127.0.0.1:9200/_cat/templates?pretty 查看 Elasticsearch 某个模板 curl -XGET 127.0.0.1:9200/_template/situation-sw_test-tem
阅读全文
摘要:创建索引 创建索引index时映射mapping put 请求发送 http://localhost:9200/blog1 参数: { "mappings": { "article": { "properties": { "id": { "type": "long", "store": true,
阅读全文
摘要:删除数据分为两种:一种是删除索引(数据和表结构同时删除,作用同SQLSERVER 中 DROP TABLE "表格名" ), 另一种是删除数据(不删除表结构,作用同SQLSERVER中Delete 语句)。 一:删除索引(结构和数据同时删除): 删除单个索引可以使用命令 【DELETE /索引名称】
阅读全文
摘要:Elasticsearch 底层并不支持更新操作,所谓的更新,是将旧的文档删除,然后索引一个新的文档。如下 查询这条数据
阅读全文
摘要:查询 organization_id 为 208 和 event_type 为 007 的数据 curl -X GET 10.44.99.102:9200/situation-event/_search?pretty -d { "query": { "bool": { "must": [{ "ter
阅读全文
摘要:Elasticsearch 添加数据 # 添加ES 数据 curl -X POST 10.44.99.102:9200/situation-event/situation-event -d {} Elasticsearch 批量添加数据 首先我们先构造一个 json文件,内容参考如下: {"inde
阅读全文
摘要:Python Elasticsearch DSL 使用简介 连接 Es: import elasticsearch clinet = elasticsearch.Elasticsearch([{"host": "10.44.99.102", "port": 9200}]) or clinet = E
阅读全文
摘要:模糊查询 { "query": { "bool": { "must": [ { "wildcard": { "assets": "*0206*" } }, { "wildcard": { "assets": "*122.14.230.69*" } } ] } } } 想找到所有title字段以cri
阅读全文
摘要:单层聚合 { "aggs": { "group_a": { "terms": { "field": "event_type" } } } } 双层聚合 { "aggs": { "group_a": { "terms": { "field": "event_type" }, "aggs": { "gr
阅读全文