opensearch dashboards 使用 :连接
OpenSearch开发环境安装Docker和Docker-Compose两种方式_opensearch docker-CSDN博客
OpenSearch 3.2.0 是一个开源的搜索引擎,基于 Elasticsearch 7.10.2。以下是关于 OpenSearch 3.2.0 镜像的相
wget https://opensearch.org/samples/docker-compose.yml
镜像 :2.7.0 (可以用)
registry.cn-hangzhou.aliyuncs.com/baimeidashu/opensearchproject:opensearch-2.7.0
registry.cn-hangzhou.aliyuncs.com/baimeidashu/opensearchproject:opensearch-dashboards-2.7.0
镜像: 3.2.0 (没跑一起来)
registry.cn-hangzhou.aliyuncs.com/baimeidashu/opensearchproject:opensearch-3.2.0
registry.cn-hangzhou.aliyuncs.com/baimeidashu/opensearchproject:opensearch-dashboards-3.2.0
docker-compose.yaml
配置文件: /usr/share/opensearch/config/opensearch.yml
version: '3.7'
services:
opensearch:
image: registry.cn-hangzhou.aliyuncs.com/baimeidashu/opensearchproject:opensearch-2.7.0
container_name: opensearch
environment:
- discovery.type=single-node
- network.host=0.0.0.0
- plugins.security.disabled=false
ports:
- "9200:9200"
- "9600:9600"
volumes:
- opensearch_data:/usr/share/opensearch/data
user: "1000:1000"
ulimits:
memlock:
soft: -1
hard: -1
nofile:
soft: 65536
hard: 65536
volumes:
opensearch_data:
启动:
docker-compose up -d
测试:
curl https://localhost:9200 -ku 'admin:admin'
安装OpenSearchDashboard
配置文件: /usr/share/opensearch-dashboards/config/opensearch_dashboards.yml
docker-compos.yaml
version: '3.7'
services:
opensearch:
image: registry.cn-hangzhou.aliyuncs.com/baimeidashu/opensearchproject:opensearch-dashboards-2.7.0
container_name: dashboards
environment:
- server.host=0.0.0.0
- OPENSEARCH_HOSTS=["https://10.0.0.250:9200"]
ports:
- "5601:5601"
访问http://ip:5601/ 。默认用户名和密码为admin
。
http://10.0.0.250:5601/
admin
admin
登录后,弹出的可以随便点一下,关掉就可以了。
使用:
我的业务数据是个json:
{
"title": "The Wind Rises",
"created_on": "2023-11-22T09:28:48+00:00",
"type": "order",
"user": "eddie",
"price": 24.99
}
在Dev Tools执行
PUT laker-index
{
"mappings": {
"properties": {
"title": {
"type": "text"
},
"created_on": {
"type": "date"
},
"type": {
"type": "keyword"
},
"user": {
"type": "keyword"
},
"price": {
"type": "half_float"
}
}
}
}
写入数据
POST _bulk
{"index":{"_index":"laker-index","_id":0}}
{"title":"The Wind Rises today is nice day","created_on":"2023-11-21T09:28:48+00:00","type":"order","user":"eddie","price":24.99}
{"index":{"_index":"laker-index","_id":1}}
{"title":"The Wind Rises","created_on":"2023-11-22T09:28:48+00:00","type":"sale","user":"eddie","price":4.99}
{"index":{"_index":"laker-index","_id":2}}
{"title":"The Wind Rises hello ","created_on":"2023-11-23T09:28:48+00:00","type":"order","user":"laker","price":34.99}
{"index":{"_index":"laker-index","_id":3}}
{"title":"The Wind Rises laker","created_on":"2023-11-22T09:28:48+00:00","type":"sale","user":"laker","price":14.99}
{"index":{"_index":"laker-index","_id":4}}
{"title":"The Wind Rises laker","created_on":"2023-11-21T09:28:48+00:00","type":"order","user":"laker","price":44.99}
查询数据
GET laker-index/_search
{
"size": 1,
"query": {
"match": {
"title": "Rises"
}
}
}
# 创建映射 mapping
# 创建映射 mapping
PUT sample-index1
{
"mappings": {
"properties": {
"year": { "type" : "text" },
"age": { "type" : "integer" },
"director":{ "type" : "text" },
"ip_address" : {
"type" : "ip",
"ignore_malformed": true
},
"timestamp": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
},
"value": {
"type": "double"
}
}
}
}
# 将映射添加到现有索引
POST sample-index1/_mapping
{
"properties": {
"year": { "type" : "text" },
"age": { "type" : "integer" },
"director":{ "type" : "text" }
}
}
# 新增文档
PUT /<index-name>/_doc/<document-id>
{
"title": "The Wind Rises",
"release_date": "2013-07-20"
}
# 搜索索引
GET /<index-name>/_search?q=wind
# 删除文档
DELETE /<index-name>/_doc/<document-id>
# 查看集群设置
GET _cluster/settings?include_defaults=true
GET _cluster/settings
# 索引列表
GET _cat/indices
green open .opensearch-observability JbwykWeAQTeyjbiEue73xw 1 0 0 0 208b 208b
yellow open security-auditlog-2023.11.22 n_D4yJoKS4-YKLI1vpyQ9w 1 1 256 0 831.7kb 831.7kb
green open .kibana_92668751_admin_1 RG79AlpgTiOhAoT2uifInw 1 0 1 0 5.1kb 5.1kb
green open .kibana_1 d88uN7czQ2eGli3Kmqcg5A 1 0 0 0 208b 208b
green open .opendistro_security JG9gJ3hARWmngXidVL89mw 1 0 10 0 43.5kb 43.5kb
# 系统状态
GET _cat/health?v
# 节点信息
GET _cat/nodes?v
# 获取映射
GET <index>/_mapping
{
"sample-index1" : {
"mappings" : {
"year" : {
"full_name" : "year",
"mapping" : {
"year" : {
"type" : "text"
}
}
},
"age" : {
"full_name" : "age",
"mapping" : {
"age" : {
"type" : "integer"
}
}
}
}
}
}
# 获取所有索引的所有映射
GET _mapping
# 获取已安装的插件
GET _cat/plugins
127296e3f35f opensearch-alerting 2.7.0.0
127296e3f35f opensearch-anomaly-detection 2.7.0.0
127296e3f35f opensearch-asynchronous-search 2.7.0.0
127296e3f35f opensearch-cross-cluster-replication 2.7.0.0
127296e3f35f opensearch-geospatial 2.7.0.0
127296e3f35f opensearch-index-management 2.7.0.0
127296e3f35f opensearch-job-scheduler 2.7.0.0
127296e3f35f opensearch-knn 2.7.0.0
127296e3f35f opensearch-ml 2.7.0.0
127296e3f35f opensearch-neural-search 2.7.0.0
127296e3f35f opensearch-notifications 2.7.0.0
127296e3f35f opensearch-notifications-core 2.7.0.0
127296e3f35f opensearch-observability 2.7.0.0
127296e3f35f opensearch-performance-analyzer 2.7.0.0
127296e3f35f opensearch-reports-scheduler 2.7.0.0
127296e3f35f opensearch-security 2.7.0.0
127296e3f35f opensearch-security-analytics 2.7.0.0
127296e3f35f opensearch-sql 2.7.0.0
索引模板
PUT _index_template/<template name>
# 创建一个名为的模板daily_logs,并将其应用于名称与模式匹配的任何新索引logs-2020-01-*,并将其添加到my_logs别名中:
PUT _index_template/daily_logs
{
"index_patterns": [
"logs-2020-01-*"
],
"template": {
"aliases": {
"my_logs": {}
},
"settings": {
"number_of_shards": 2,
"number_of_replicas": 1
},
"mappings": {
"properties": {
"timestamp": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
},
"value": {
"type": "double"
}
}
}
}
}
# 如果您创建名为 的索引logs-2020-01-01,您可以看到它具有模板中的映射和设置:
PUT logs-2020-01-01
GET logs-2020-01-01
{
"logs-2020-01-01": {
"aliases": {
"my_logs": {}
},
"mappings": {
"properties": {
"timestamp": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
},
"value": {
"type": "double"
}
}
},
"settings": {
"index": {
"creation_date": "1578107970779",
"number_of_shards": "2",
"number_of_replicas": "1",
"uuid": "U1vMDMOHSAuS2IzPcPHpOA",
"version": {
"created": "7010199"
},
"provided_name": "logs-2020-01-01"
}
}
}
}
欢迎来撩 : 汇总all