做网站应该用什么配置的手提电脑,网站建设要学哪些软件有哪些内容,seo公司的选上海百首网络,电子商务网站建设的一般一、基本命令 1、获取所有_cat命令
curl -X GET localhost:9200/_cat
2、获取es集群服务健康状态
curl -X GET localhost:9200/_cat/health?v
epoch: 时间戳的 Unix 时间戳格式#xff0c;表示快照生成的时间。 timestamp: 可读性更强的时间戳格式#xff0c;表示快照生… 一、基本命令 1、获取所有_cat命令
curl -X GET localhost:9200/_cat
2、获取es集群服务健康状态
curl -X GET localhost:9200/_cat/health?v
epoch: 时间戳的 Unix 时间戳格式表示快照生成的时间。 timestamp: 可读性更强的时间戳格式表示快照生成的时间08:06:34。 cluster: Elasticsearch 集群的名称这里是 es-cluster。 status: 集群的健康状态这里是 yellow。Elasticsearch 集群状态通常有三种green绿色健康yellow黄色部分健康red红色不健康。yellow 状态表示集群中的某些副本不可用但主分片是可用的。 node.total: 集群中节点的总数这里是 1 个节点。 node.data: 充当数据节点的节点数这里是 1 个节点。 shards: 集群中分片的总数这里是 98 个分片。 pri: 主分片primary shard的数量这里是 98 个主分片。 relo: 正在进行重新定位的分片数量这里是 0。 init: 初始化的分片数量这里是 0。 unassign: 未分配的分片数量这里是 27。 pending_tasks: 挂起的任务数这里是 0。 max_task_wait_time: 最大任务等待时间这里是没有具体数值。 active_shards_percent: 活动分片的百分比这里是 78.4%。这表示在集群中有 78.4% 的分片是活动的而剩下的可能是不可用或者正在恢复的。 3、查看es节点信息
curl -X GET localhost:9200/_cat/nodes?v
ip: 节点的IP地址这里是192.168.52.11。 heap.percent: 节点的堆内存使用百分比这里是67%。 ram.percent: 节点的系统内存使用百分比这里是98%。 cpu: 节点的CPU使用率这里是10%。 load_1m: 1分钟负载平均值这里是0.69。 load_5m: 5分钟负载平均值这里是0.36。 load_15m: 15分钟负载平均值这里是0.50。 node.role: 节点的角色这里是*表示这是一个主节点master node。 master: 指示该节点是否是主节点这里是*表示它是主节点。 name: 节点的名称这里是node-1。 4、查看es指定节点信息
curl -X GET localhost:9200/_nodes/node-1?prettytrue
二、索引操作 1、查看ES中所有的索引
curl -X GET localhost:9200/_cat/indices?v
health: 索引的健康状态这里是 yellow。Elasticsearch 索引的健康状态有三种green绿色健康yellow黄色部分健康red红色不健康。yellow 状态表示索引的某些分片处于未分配状态但主分片是可用的。 status: 索引的状态这里是 open。这表示索引处于打开状态可以进行读取和写入操作。 index: 索引的名称这里是 nginx-access-log-2023.09.13。 uuid: 索引的唯一标识符。 pri: 主分片primary shard的数量这里是 1 个主分片。 rep: 副本分片replica shard的数量这里也是 1 个副本分片。 docs.count: 索引中文档的总数这里是 20。 docs.deleted: 索引中已删除的文档数量这里是 0。 store.size: 索引的存储大小这里是 34.1KB。 pri.store.size: 主分片的存储大小这里也是 34.1KB。 2、新建索引
curl -X PUT localhost:9200/testyf
3、新建索引并增加数据 POST /索引/端点
POST /data/_bulk
{ index: { _id: 1 }}
{ articleID : XHDK-A-1293-#fJ3, userID : 1, hidden: false, postDate: 2022-01-01 }
{ index: { _id: 2 }}
{ articleID : KDKE-B-9947-#kL5, userID : 1, hidden: false, postDate: 2022-01-02 }
4、追加数据 # 追加新增字段
POST /data/_bulk
{update:{_id:1}}
{doc:{title:this is java and elasticsearch blog}}
5、删除索引
curl -X DELETE localhost:9200/testyf
6、查看指定索引信息
curl -X GET localhost:9200/nginx-access-log-2023.09.13?pretty
7、查看索引的统计信息
curl -X GET localhost:9200/nginx-access-log-2023.09.13/_stats?pretty
三、文档操作 一查询索引中的全部文档
curl -X GET localhost:9200/nginx-access-log-2023.09.13/_search?pretty
注意?pertty 表示让数据格式化更好的展示 2根据条件查询索引中的文档 单一条件搜索 1、搜索 response_code 包含 200
POST /nginx-access-log-2023.09.13/_search?pretty
{query: {match: {response_code: 200}}
}
2、搜索 message 包含 34 或者 包含 36
POST /nginx-access-log-2023.09.25/_search?pretty
{query: {match: {message: 34 36}},size: 1000
}
3、搜索 message 包含 34 并且 包含 36
POST /nginx-access-log-2023.09.25/_search?pretty
{query: { match: { message: {query: 34 36,operator: and}} },size: 1000
} 4、搜索 message 包含 34 36 15 22 中超过 50% 以上比例的
POST /nginx-access-log-2023.09.25/_search?pretty
{query: { match: { message: {query: 34 36 15 22,minimum_should_match: 50%}} },size: 1000
} 5、使用sort对查询数据排序并按照size返回查询的数量desc降序 / asc升序
GET /data/_search?size2
{query: {match: {title: java elasticsearch}},sort: {postDate: {order: desc}}
}
多条件搜索 1、使用 must 搜索 response_code 包含 200并且 timestamp 包含 2023-09-25T12:43:46.000Z
POST /nginx-access-log-2023.09.25/_search?pretty
{query: {bool: {must: [{match: {response_code: 200}},{match: {timestamp: 2023-09-25T12:43:46.000Z}}]}},size: 100
}
2、|| 使用 should 搜索 response_code 包含 200或者 timestamp 包含 2023-09-25T12:43:46.000Z
POST /nginx-access-log-2023.09.25/_search?pretty
{query: {bool: {should: [{match: {response_code: 200}},{match: {timestamp: 2023-09-25T12:43:46.000Z}}]}},size: 100
} 3、|| 使用 should 搜索 response_code 包含 200或者 timestamp 包含 2023-09-25T12:43:46.000Z或者 message 包含 Windows至少满足2个以上
POST /nginx-access-log-2023.09.25/_search?pretty
{query: {bool: {should: [{match: {response_code: 200}},{match: {timestamp: 2023-09-25T12:43:46.000Z}},{match: {message: Windows}}],minimum_should_match: 2}},size: 100
}
4、搜索 response_code 包含 200并且 timestamp 不包含 2023-09-25T12:43:46.000Z
POST /nginx-access-log-2023.09.25/_search?pretty
{query: {bool: {must: [{match: {response_code: 200}}],must_not: [{match: {timestamp: 2023-09-25T12:43:46.000Z}}]}},size: 100
} 5、统计 response_code 包含 200 的有多少个
POST /nginx-access-log-2023.09.25/_count?pretty
{query: {bool: {must: [{match: {response_code: 200}}]}}
} 3转换 term不分词直接匹配字段的完整值 match根据字段的分词器对搜索文本进行分词
1、普通match如何转换为termshould 转换前
GET /data/_search
{query: {match: {title: java elasticsearch}}
}
转换后
GET /data/_search
{query: {bool: {should: [{term: {title: java}},{term: {title: elasticsearch}}]}}
}
2、and match如何转换为termmust 转换前
GET /data/_search
{query: {match: {title: {query: java elasticsearch,operator: and}}}
}
转换后
GET /data/_search
{query: {bool: {must: [{term: {title: java}},{term: {title: elasticsearch}}]}}
}
3、minimum_should_match如何转换 转换前
GET /data/_search
{query: {match: {title: {query: java elasticsearch hadoop spark,minimum_should_match: 75%}}}
}
转换后
GET /data/_search
{query: {bool: {should: [{term: {title: java}},{term: {title: elasticsearch}},{term: {title: hadoop}},{term: {title: spark}}],minimum_should_match: 3}}
}