跳到主要内容

快速开始

从零开始,为应用集成云端搜索只需2分钟。

创建应用

进入控制台,创建一个免费的 Elasticsearch 集群,只需5秒钟。

进入应用

为了保护数据交互的安全性,纳速云平台默认会屏蔽您的云上集群可见性,只有添加到白名单的机器才能访问集群。

一键添加本机IP到白名单

KIBANA

进入 Kibana - 开发工具 测试常用的索引写入查询操作

# 写入索引

POST foo/_doc
{
"message":"hello world"
}

# 检索数据

GET foo/_search
{
"query": {
"match_all": {}
}
}

连接客户端

主页概览 \ 连接信息 获取集群的服务器地址、用户名及密码

如果你擅长以下技术栈,几行代码快速连接到云端 Elasticsearch API。

Any Where

不在需要部署任何集群环境,支持您在互联网上任意位置集成搜索能力。

连接 Java

也可以尝试用一个Java应用连接云端集群,快速体验索引的增删改查,掌握常备的搜索开发技能。

git clone git@github.com:nasuyun/example-springboot.git

cd example-springboot

## 修改配置替换成应用的用户名及密码
vi src/main/resources/application.properties

mvn clean package

java -jar ./target/example-springboot-0.0.1.jar

curl 命令行测试

无需任何开发工具,运用命令行测试云端 ES API,是一种高效的调试方式。

curl -XPOST 'https://router.nasuyun.com:9200/logs/_doc' -H 'Content-Type: application/json' \
-u your_username:your_password \
-d '
{
"timestamp": "2018-01-24 12:34:56",
"message": "User logged in",
"user_id": 4,
"admin": false
}'

如返回如下结果 表明数据写入成功

{
"_index": "logs",
"_type": "_doc",
"_id": "euuBFIIBcnPik3fA8c8y",
"_version": 1,
"result": "created",
"_shards": {
"total": 2,
"successful": 1,
"failed": 0
},
"_seq_no": 0,
"_primary_term": 1
}

测试API搜索文档

curl -XPOST 'https://router.nasuyun.com:9200/logs/_search?pretty' -u your_username:your_password

{
"took" : 2,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : 1,
"max_score" : 1.0,
"hits" : [
{
"_index" : "logs",
"_type" : "_doc",
"_id" : "euuBFIIBcnPik3fA8c8y",
"_score" : 1.0,
"_source" : {
"timestamp" : "2018-01-24 12:34:56",
"message" : "User logged in",
"user_id" : 4,
"admin" : false
}
}
]
}
}