Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add cn doc #708

Merged
merged 3 commits into from
Sep 13, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
109 changes: 109 additions & 0 deletions docs-2.0/3.ngql-guide/6.functions-and-expressions/13.concat.md
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 string is `NULL`, `NULL` is returned.
randomJoe211 marked this conversation as resolved.
Show resolved Hide resolved

### 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" |
+---------------------------------+
```
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.|
103 changes: 103 additions & 0 deletions docs-2.0/7.data-security/1.authentication/4.ldap.md
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`)无法正常登录。
-->
53 changes: 53 additions & 0 deletions docs-2.0/8.service-tuning/improve-query-by-tag-index.md
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>;`语句重建索引。
-->
6 changes: 6 additions & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ nav:
- collect(): 3.ngql-guide/6.functions-and-expressions/10.collect.md
- reduce(): 3.ngql-guide/6.functions-and-expressions/11.reduce.md
- hash(): 3.ngql-guide/6.functions-and-expressions/12.hash.md
- concat(): 3.ngql-guide/6.functions-and-expressions/13.concat.md
- Predicate functions: 3.ngql-guide/6.functions-and-expressions/8.predicate.md
- User-defined functions: 3.ngql-guide/6.functions-and-expressions/9.user-defined-functions.md

Expand Down Expand Up @@ -189,6 +190,7 @@ nav:
- SHOW USERS: 3.ngql-guide/7.general-query-statements/6.show/16.show-users.md
- SHOW SESSIONS: 3.ngql-guide/7.general-query-statements/6.show/17.show-sessions.md
- SHOW QUERIES: 3.ngql-guide/7.general-query-statements/6.show/18.show-queries.md
- SHOW META LEADER: 3.ngql-guide/7.general-query-statements/6.show/19.show-meta-leader.md

- Clauses and options:
- GROUP BY: 3.ngql-guide/8.clauses-and-options/group-by.md
Expand All @@ -213,6 +215,8 @@ nav:
- ALTER TAG: 3.ngql-guide/10.tag-statements/3.alter-tag.md
- SHOW TAGS: 3.ngql-guide/10.tag-statements/4.show-tags.md
- DESCRIBE TAG: 3.ngql-guide/10.tag-statements/5.describe-tag.md
- DELETE TAG: 3.ngql-guide/10.tag-statements/6.delete-tag.md

- Edge type statements:
- CREATE EDGE: 3.ngql-guide/11.edge-type-statements/1.create-edge.md
- DROP EDGE: 3.ngql-guide/11.edge-type-statements/2.drop-edge.md
Expand Down Expand Up @@ -295,6 +299,7 @@ nav:
- Authentication: 7.data-security/1.authentication/1.authentication.md
- User management: 7.data-security/1.authentication/2.management-user.md
- Roles and privileges: 7.data-security/1.authentication/3.role-list.md
- OpenLDAP authentication: 7.data-security/1.authentication/4.ldap.md
# - Backup & Restore:
# - What is Backup & Restore: 7.data-security/2.backup-restore/1.what-is-br.md
# - Compile BR: 7.data-security/2.backup-restore/2.compile-br.md
Expand All @@ -309,6 +314,7 @@ nav:
- System design suggestions: 8.service-tuning/3.system-design.md
- Execution plan: 8.service-tuning/4.plan.md
- Processing super vertices: 8.service-tuning/super-node.md
- Add or delete tag: 8.service-tuning/improve-query-by-tag-index.md

- Client:
- Clients overview: 14.client/1.nebula-client.md
Expand Down