-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add cn doc * concat and show meta leader * Update 13.concat.md Co-authored-by: 朱晓青 <[email protected]>
- Loading branch information
1 parent
7b05a22
commit 8dab0bb
Showing
5 changed files
with
298 additions
and
0 deletions.
There are no files selected for viewing
109 changes: 109 additions & 0 deletions
109
docs-2.0/3.ngql-guide/6.functions-and-expressions/13.concat.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
# concat function | ||
|
||
The `concat()` and `concat_ws()` functions return strings concatenated by one or more strings. | ||
|
||
## concat() function | ||
|
||
The `concat()` function requires at least two or more strings. All the parameters are concatenated into one string. | ||
|
||
- If there is only one string, the string itself is returned. | ||
|
||
- If any one of the strings is `NULL`, `NULL` is returned. | ||
|
||
### Syntax | ||
|
||
```bash | ||
concat(string1,string2,...) | ||
``` | ||
|
||
### Examples | ||
|
||
```bash | ||
//This example concatenates 1, 2, and 3. | ||
nebula> RETURN concat("1","2","3") AS r; | ||
+-------+ | ||
| r | | ||
+-------+ | ||
| "123" | | ||
+-------+ | ||
|
||
//In this example, one of the string is NULL. | ||
nebula> RETURN concat("1","2",NULL) AS r; | ||
+----------+ | ||
| r | | ||
+----------+ | ||
| __NULL__ | | ||
+----------+ | ||
|
||
nebula> GO FROM "player100" over follow \ | ||
YIELD concat(follow._src, $^.player.age, $$.player.name, follow.degree) AS A; | ||
+------------------------------+ | ||
| A | | ||
+------------------------------+ | ||
| "player10042Tony Parker95" | | ||
+------------------------------+ | ||
| "player10042Manu Ginobili95" | | ||
+------------------------------+ | ||
``` | ||
|
||
## concat_ws() function | ||
|
||
The `concat_ws()` function connects two or more strings with a predefined separator. | ||
|
||
- If the separator is `NULL`, the `concat_ws()` function returns `NULL`. | ||
|
||
- If the separator is not `NULL` and there is only one string, the string itself is returned. | ||
|
||
- If the separator is not `NULL` and there is a `NULL` in the strings, `NULL` is ignored during the concatenation. | ||
|
||
### Syntax | ||
|
||
```bash | ||
concat_ws(separator,string1,string2,... ) | ||
``` | ||
|
||
### Examples | ||
|
||
```bash | ||
//This example concatenates a, b, and c with the separator +. | ||
nebula> RETURN concat_ws("+","a","b","c") AS r; | ||
+---------+ | ||
| r | | ||
+---------+ | ||
| "a+b+c" | | ||
+---------+ | ||
|
||
//In this example, the separator is NULL. | ||
neubla> RETURN concat_ws(NULL,"a","b","c") AS r; | ||
+----------+ | ||
| r | | ||
+----------+ | ||
| __NULL__ | | ||
+----------+ | ||
|
||
//In this example, the separator is + and there is a NULL in the strings. | ||
nebula> RETURN concat_ws("+","a",NULL,"b","c") AS r; | ||
+---------+ | ||
| r | | ||
+---------+ | ||
| "a+b+c" | | ||
+---------+ | ||
|
||
//In this example, the separator is + and there is only one string. | ||
nebula> RETURN concat_ws("+","a") AS r; | ||
+-----+ | ||
| r | | ||
+-----+ | ||
| "a" | | ||
+-----+ | ||
|
||
nebula> GO FROM "player100" over follow \ | ||
YIELD concat_ws(" ",follow._src, $^.player.age, $$.player.name, follow.degree) AS A; | ||
+---------------------------------+ | ||
| A | | ||
+---------------------------------+ | ||
| "player100 42 Tony Parker 95" | | ||
+---------------------------------+ | ||
| "player100 42 Manu Ginobili 95" | | ||
+---------------------------------+ | ||
``` |
27 changes: 27 additions & 0 deletions
27
docs-2.0/3.ngql-guide/7.general-query-statements/6.show/19.show-meta-leader.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# SHOW META LEADER | ||
|
||
The `SHOW META LEADER` statement shows the information of the leader in the current Meta cluster. | ||
|
||
For more information about the Meta service, see [Meta service](../../../1.introduction/3.nebula-graph-architecture/2.meta-service.md). | ||
|
||
## Syntax | ||
|
||
```ngql | ||
SHOW META LEADER; | ||
``` | ||
|
||
## Example | ||
|
||
```ngql | ||
nebula> SHOW META LEADER; | ||
+------------------+---------------------------+ | ||
| Meta Leader | secs from last heart beat | | ||
+------------------+---------------------------+ | ||
| "127.0.0.1:9559" | 3 | | ||
+------------------+---------------------------+ | ||
``` | ||
|
||
|Parameter|Description| | ||
|:---|:---| | ||
|`Meta Leader`|Shows the information of the leader in the Meta cluster, including the IP address and port of the server where the leader is located.| | ||
|`secs from last heart beat`|Indicates the time interval since the last heartbeat. This parameter is measured in seconds.| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
<!-- | ||
# 使用OpenLDAP进行身份验证 | ||
本文介绍如何将Nebula Graph连接到OpenLDAP服务器,使用OpenLDAP中定义的DN(Distinguished Name)和密码进行身份验证。 | ||
!!! enterpriseonly | ||
仅企业版支持本功能。 | ||
## 认证方式 | ||
启用OpenLDAP身份验证后,输入用户的账号和密码登录Nebula Graph时,Nebula Graph会在Meta服务中查找登录账号是否存在,如果账号存在,再根据认证方式去OpenLDAP中找到对应的DN,验证密码。 | ||
OpenLDAP支持的认证方式有两种:简单绑定认证和搜索绑定认证。 | ||
### 简单绑定认证(SimpleBindAuth) | ||
简单绑定认证会根据登录账号和Graph服务配置信息,拼接成OpenLDAP可以识别的DN,然后根据DN和密码,在OpenLDAP上进行验证。 | ||
### 搜索绑定认证(SearchBindAuth) | ||
搜索绑定认证会读取Graph服务配置信息,查询配置信息中的`uid`和登录账号是否匹配,如果匹配,就读取这个DN,然后用DN和密码,在OpenLDAP上进行验证。 | ||
## 前提条件 | ||
- 已安装[OpenLDAP](https://www.openldap.org/)。 | ||
- 已在OpenLDAP上导入用户的账号和密码信息。 | ||
- OpenLDAP所在服务器已开放相应认证端口。 | ||
## 操作步骤 | ||
以OpenLDAP上已存在的账号`test2`、密码`passwdtest2`为例进行演示。 | ||
1. [连接Nebula Graph](../../4.deployment-and-installation/connect-to-nebula-graph.md),创建与OpenLDAP中对应的影子账号`test2`并授权。 | ||
```ngql | ||
nebula> CREATE USER test2 WITH PASSWORD ''; | ||
nebula> GRANT ROLE ADMIN ON basketballplayer TO test2; | ||
``` | ||
!!! note | ||
Nebula Graph内创建用户时,密码可以任意设置。 | ||
2. 编辑配置文件`nebula-graphd.conf`(默认目录为`/usr/local/nebula/etc/`): | ||
- 简单绑定认证(推荐) | ||
```bash | ||
# 是否从配置文件获取配置信息。 | ||
--local_config=true | ||
# 是否开启身份验证 | ||
--enable_authorize=true | ||
# 身份验证方式:password、ldap、cloud | ||
--auth_type=ldap | ||
# OpenLDAP服务器地址 | ||
--ldap_server=192.168.8.211 | ||
# OpenLDAP服务器端口 | ||
--ldap_port=389 | ||
# OpenLDAP中的Schema名称 | ||
--ldap_scheme=ldap | ||
# DN前缀 | ||
--ldap_prefix=uid= | ||
# DN后缀 | ||
--ldap_suffix=,ou=it,dc=sys,dc=com | ||
``` | ||
- 搜索绑定认证 | ||
```bash | ||
# 是否从配置文件获取配置信息。 | ||
--local_config=true | ||
# 是否开启身份验证 | ||
--enable_authorize=true | ||
# 身份验证方式:password、ldap、cloud | ||
--auth_type=ldap | ||
# OpenLDAP服务器地址 | ||
--ldap_server=192.168.8.211 | ||
# OpenLDAP服务器端口 | ||
--ldap_port=389 | ||
# OpenLDAP中的Schema名称 | ||
--ldap_scheme=ldap | ||
# 绑定目标对象的DN | ||
--ldap_basedn=uid=test2,ou=it,dc=sys,dc=com | ||
``` | ||
3. [重启Nebula Graph服务](../../4.deployment-and-installation/manage-service.md),让新配置生效。 | ||
4. 进行登录测试。 | ||
```bash | ||
$ ./nebula-console --addr 127.0.0.1 --port 9669 -u test2 -p passwdtest2 | ||
2021/09/08 03:49:39 [INFO] connection pool is initialized successfully | ||
Welcome to Nebula Graph! | ||
``` | ||
!!! note | ||
使用OpenLDAP进行身份验证后,本地用户(包括`root`)无法正常登录。 | ||
--> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<!--> | ||
# 增加和删除标签 | ||
|
||
在openCypher中,有增加标签(`SET label`)和移除标签(`REMOVE label`)的功能,可以用于加速查询或者标记过程。 | ||
|
||
在Nebula Graph中,可以通过Tag变相实现相同操作,创建Tag并将Tag插入到已有的点上,就可以根据Tag名称快速查找点,也可以通过`DELETE TAG`删除某些点上不再需要的Tag。 | ||
|
||
!!! caution | ||
|
||
请确保点上已经有另一个Tag,否则删除点上最后一个Tag时,会导致点也被删除。 | ||
|
||
## 示例 | ||
|
||
例如在basketballplayer数据集中,部分篮球运动员同时也是球队股东,可以为股东Tag`shareholder`创建索引,方便快速查找。如果不再是股东,可以通过`DELETE TAG`语句删除相应运动员的股东Tag。 | ||
|
||
```ngql | ||
//创建股东Tag和索引 | ||
nebula> CREATE TAG shareholder(); | ||
nebula> CREATE TAG INDEX shareholder_tag on shareholder(); | ||
//为点添加Tag | ||
nebula> INSERT VERTEX shareholder() VALUES "player100":(); | ||
nebula> INSERT VERTEX shareholder() VALUES "player101":(); | ||
//快速查询所有股东 | ||
nebula> MATCH (v:shareholder) RETURN v; | ||
+---------------------------------------------------------------------+ | ||
| v | | ||
+---------------------------------------------------------------------+ | ||
| ("player100" :player{age: 42, name: "Tim Duncan"} :shareholder{}) | | ||
+---------------------------------------------------------------------+ | ||
| ("player101" :player{age: 36, name: "Tony Parker"} :shareholder{}) | | ||
+---------------------------------------------------------------------+ | ||
nebula> LOOKUP ON shareholder; | ||
+-------------+ | ||
| VertexID | | ||
+-------------+ | ||
| "player100" | | ||
+-------------+ | ||
| "player101" | | ||
+-------------+ | ||
//如果player100不再是股东 | ||
nebula> DELETE TAG shareholder FROM "player100"; | ||
nebula> LOOKUP ON shareholder; | ||
+-------------+ | ||
| VertexID | | ||
+-------------+ | ||
| "player101" | | ||
+-------------+ | ||
``` | ||
|
||
!!! note | ||
|
||
如果插入测试数据后才创建索引,请用`REBUILD TAG INDEX <index_name_list>;`语句重建索引。 | ||
--> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters